I am trying to assign an IP to lxc so that it become visible to other machine on network. host-machine:~$ /etc/network/interfaces

auto lo
iface lo inet loopback

auto enp4s0
iface enp4s0 inet manual

auto br0
iface br0 inet dhcp
        bridge_ports enp4s0
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0

host-machine:~$ cat .local/share/lxc/elastic/config

lxc.include = /usr/share/lxc/config/ubuntu.common.conf
lxc.include = /usr/share/lxc/config/ubuntu.userns.conf
lxc.arch = x86_64
# Container specific configuration
lxc.id_map = u 0 100000 65536
lxc.id_map = g 0 100000 65536
# Network configuration

lxc.network.type = veth 
lxc.network.flags = up 
lxc.network.link = br0
lxc.network.name = eth0
lxc.network.mtu = 1500
lxc.network.hwaddr = 00:16:3e:c9:7a:92
lxc.rootfs = /home/nitigyasharma/.local/share/lxc/elastic/rootfs
lxc.rootfs.backend = dir
lxc.utsname = elastic

host-machine:~$ cat .local/share/lxc/elastic/rootfs/etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

My network interfaces are

2: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
    link/ether c8:5b:76:fa:6d:93 brd ff:ff:ff:ff:ff:ff
    inet brd scope global dynamic enp4s0
       valid_lft 3569sec preferred_lft 3569sec
    inet brd scope global secondary enp4s0
       valid_lft forever preferred_lft forever
3: wlp5s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 3c:95:09:43:7e:c7 brd ff:ff:ff:ff:ff:ff
25: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether c8:5b:76:fa:6d:93 brd ff:ff:ff:ff:ff:ff
    inet brd scope global br0
       valid_lft forever preferred_lft forever
    inet6 fe80::ca5b:76ff:fefa:6d93/64 scope link 
       valid_lft forever preferred_lft forever

but I am not able to ping from host machine and lxc do not get network IP at all


Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         UG    0      0        0 br0        *          U     0      0        0 enp4s0        *          U     0      0        0 br0

output of lxc-info

host-machine-:~$ lxc-info -n elastic 
Name:           elastic
State:          RUNNING
PID:            3772
Memory use:     31.73 MiB
KMem use:       0 bytes
Link:           veth1VQMEE
 TX bytes:      1.63 KiB
 RX bytes:      4.76 KiB
 Total bytes:   6.40 KiB
  • Well...where should it get its IP from? Do you have a running DHCP server on your host? Or does your host forward DHCP requests? Add the ouptut of lxc info <containername> please
    – Lenniey
    Aug 8 '17 at 12:32
  • well I do not have a dhcp server on host. I actually do not understand very well how I should do this dhcp stuff Aug 8 '17 at 12:56
  • And what is on your network?
    – Lenniey
    Aug 9 '17 at 14:08
  • that;s my firewall Aug 9 '17 at 18:56
  • Your LXC guest doesn't even get an IP. Try setting one manually and then check why it won't get one via DHCP.
    – Lenniey
    Aug 10 '17 at 4:37

Your Answer

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

Browse other questions tagged or ask your own question.