1

When I run lxd init I choose this setting.

Would you like to create a new network bridge (yes/no)? no

because I created my own br0 in /etc/network/interfaces

source /etc/network/interfaces.d/*

auto lo
iface lo inet loopback

auto br0
iface br0 inet static
    address x.x.50.2
    netmask 255.255.252.0
    broadcast x.x.x.255
    network x.x.x.0
    gateway x.x.53.254
    dns-nameservers 8.8.8.8

    bridge_ports eth0
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0

iface eth0 inet manual

Then I launch lxd centos and run

 lxc config device add first eth0 nic nictype=bridged parent=br0
 lxc config device set first eth0 ipv4.address x.x.51.2
 lxc config device set first eth0 security.mac_filtering true

and change configuration in

 /var/lib/lxd/containers/second/rootfs/etc/sysconfig/network-scripts/ifcfg-eth0

 DEVICE=eth0
 BOOTPROTO=none
 ONBOOT=yes
 HOSTNAME=LXC_NAME
 NM_CONTROLLED=no
 TYPE=Ethernet
 IPADDR=x.x.51.2
 NETMASK=255.255.255.255
 GATEWAY=x.x.53.254
 DNS1=8.8.8.8
 DNS2=x.x.x.x
 MTU=
 DHCP_HOSTNAME=x.x.50.2

When I try ping 8.8.8.8 I get Connection: Network is Unreachable

/etc/resolv.conf

 nameserver 8.8.8.8
 search lxd
 nameserver x.x.x.x

What am I doing wrong I cannot figure out, maybe I'm missing some conception?

cyprian
  • 111
  • 2

1 Answers1

0

Are you using a dedicated NIC for your containers? You shouldn't need to set a static IP address on your bridge:

auto br0
iface br0 inet manual
    bridge_ports eth0
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0

iface eth0 inet manual

And if you are setting your IP address inside your consider, I tend to not set it at the lxc config level either

lxc config device unset first eth0 ipv4.address

If you are sharing your management interface to the LXD host with the LXD containers, then you can reset the IP address on the the bridge, but I would recommend using separate devices for the two connections.

If none of that works, you need to find where the network is broken at. I take a step-by-step approach outside the container and then inside the container, which involve checking the network access at various levels:

  1. On the host:
    • Temporarily remove the bridge from your configuration (just comment it out) and set a static IP address on eth0.
      • Can you ping eth0 ping 192.168.0.10? If yes, then eth0 is up and working. If no, then you have an issue with your NIC.
      • Can you ping the gateway ping 192.168.0.1? If yes, then layer 2 connectivity is working. If no, then you have a layer 2 issue. Check your connections, switch, etc (any MAC based filtering).
      • Can you ping outside the gateway ping 8.8.8.8? If yes, then layer 3 connectivity is working. If no, then you most likely have a layer 3 issue. Check routing table ip route show, router, etc.
    • If all of those are working you know that eth0 is working perfectly. Now you create your bridge again, set eth0 back to manual and give it that IP address to your bridge. Repeat the 3 sub steps above. If all of them succeed then you know that the problem isn't on the host, it is on the container.
    • Remove the IP address from your bridge and set it back to manual. Continue to the next step.
  2. In the container:
    • Can you ping eth0 ping 192.168.0.10? If yes, then the NIC is working, continue. If No, then there is a problem with the NIC itself, you won't get any network connectivity. Check LXD logs, Kernel logs, run Ethernet tests, etc. If this is the case then the problem is most likely a configuration issue as you would have already tested the actual eth0 device on the host and found that it was working to get this far.
    • Can you ping the gateway ping 192.168.0.1? If yes, then layer 2 is working, continue. If no, then you have a layer 2 issue.
    • Can you ping outside the gateway (we already know you can't) ping 8.8.8.8? There is a layer 3 issue. Check routes ip route show