1

Network Setup

  • I have a server which I am trying to set up LXCs on
  • I am using LXD which forces me to use DHCP
  • DHCP is working fine already
  • due to my setup I need to be able to access the containers using their hostnames
    • this works now using the .local TLD

Problem

The problem now is that I need to access the containers using their hostnames from the host too which does not receive it's configuration from the DHCP server. Currently this does not work.

Edit

This does work when I set the DNS server of the host interface to it's own ip. I still cannot ping the host from anywhere.

Workaround

I could just put the host with it's ip in the host's /etc/hosts file, but I am not sure if this is the right way to do it.

Host Setup

The host is running Gentoo GNU/Linux 4.1.5 (OpenRC).

/etc/conf.d/net looks as follows:

dns_servers="8.8.8.8 8.8.4.4"

config_eth0="<static IP>"
routes_eth0="default via <static gateway>"
fallback_eth0="dhcp"


rc_net_lxcbr0_provide="!net"

config_lxcbr0="10.2.0.1/24"
brctl_lxcbr0="setfd 0
sethello 10
stp off"
bridge_lxcbr0=""

dns_domain_lxcbr0="local"
dns_servers_lxcbr0="10.2.0.1 8.8.8.8 8.8.4.4"

dnsmasq is configured like this (comments removed):

local=/local/
interface=lxcbr0
listen-address=10.2.0.1
expand-hosts
domain=local,10.2.0.0/24
dhcp-range=10.2.0.2,10.2.0.128,255.255.255.0,12h
dhcp-range=<static ip range>, 12h
enable-ra

Container Setup

The containers just run their DHCP client.

Hostnames

Let's just assume those:

  • host
  • cont1
  • cont2

Pings

The upper row shows who is pinged. The left column shows who is pinging.

Pings are run in the form ping <machine>.local e.g.: ping host.local.

+-------+-------+-------+-------+
|       | host  | cont1 | cont2 |
+-------+-------+-------+-------+
| host  |  no   |  yes  |  yes  |
+-------+-------+-------+-------+
| cont1 |  no   |  yes  |  yes  |
+-------+-------+-------+-------+
| cont2 |  no   |  yes  |  yes  |
+-------+-------+-------+-------+
1

The solution was to just add 10.2.0.1 as a DNS server on the host and to add the following lines to /etc/dnsmasq.conf:

address=/host.local/10.2.0.1
address=/host.local/<ipv6 address>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.