Issue accessing container using hostname

russellhq

New Member
Dec 23, 2022
4
0
1
I'm trying to access my containers using their hostnames but I can't get it to work, I can only access them using their IP address. I've checked DNS and DHCP settings but don't see anything out of place: see below.

Also, I noticed in pfSense, which runs my DHCP server, the containers are listed in the DHCP leases but only show an IP address rather than a hostname like the other hosts in the DHCP leases list.

I've checked the settings in proxmox and I think I have them all set correctly but I still have this issue.

The container hostname
Bash:
root@docker ~# hostname -f
docker.local.lan

Code:
  GNU nano 5.4         /etc/hosts                   
127.0.0.1 localhost
127.0.1.1 core

#Required for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
# --- BEGIN PVE ---
127.0.1.1 docker.local.lan docker
# --- END PVE ---

/etc/resolv.conf
Code:
# --- BEGIN PVE ---
search local.lan
nameserver 192.168.1.2
# --- END PVE ---

In pfSense, I have the DNS resolver set with both the following options on which should pick up the hostnames of the containers when they request an IP:
Register DHCP static mappings in the DNS Resolver
Register DHCP leases in the DNS Resolver

The DHCP server on pfSense also has the "Domain Name" option set to local.lan

I can access proxmox using its hostname. But I think that's only because I've mapped it to a static IP in pfSense

The proxmox ve node hosts.
Code:
127.0.0.1 localhost.localdomain localhost
192.168.1.219 proxmoxve.local.lan proxmoxve

# The following lines are desirable for IPv6 capable hosts

::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Any help getting this sorted would really be appreciated.
 
I normally set my CT/VM's up with static addresses in pfsense DHCP server settings, that way I know where they will land. You need to add the mac address of the CT/VM and pair it with an IP address, fill out host name and ensure you tick ARP Table Static Entry
 
  • Like
Reactions: russellhq
Thanks, I did that with my proxmox node, but wanted to avoid having to do that for the containers. Thanks for the suggestion though.
 
I'm getting a bit closer to getting this working,
I added 127.0.1.1 to the DNS servers in the proxmox node AND i turned off the proxmox node firewall. This allowed me to connect to the container using its hostname (but not its FQDN). Either of these changes on their own didn't work.

I turned the firewall back on but set up 2 rules to allow DHCP traffic, following the post below. I was still able to connect to the container using the hostname (but still not the FQDN).
https://forum.proxmox.com/threads/firewall-dhcp-enabled.41143/
 
OK, I don't need to set up the firewall rules in the proxmode node. I can delete those rules and just change the firewall option in the container. Under the containers firewall options, changing the DHCP setting to No allows the container to be accessed using its hostname. Still can't access it with FQDN yet.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!