Problem to configure bridge in lxc containers


(gery escalier) #1

Hello I could not configure the bridge mode so that my containers have an internet connection

Server Debian 9 LXC

~ $ ip addres show
1: lo: <LOOPBACK, UP, LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link / loopback 00: 00: 00: 00: 00: 00 brd 00: 00: 00: 00: 00: 00
    inet 127.0.0.1/8 scope host what
       valid_lft forever preferred_lft forever
    inet6 :: 1/128 scope host
       valid_lft forever preferred_lft forever
2: enp3s0: <BROADCAST, MULTICAST, UP, LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link / ether 74: d4: 35: 5e: e0: 7a brd ff: ff: ff: ff: ff: ff
    inet 192.168.0.223/24 brd 192.168.0.255 scope global dynamic enp3s0
       valid_lft 4966sec preferred_lft 4966sec
    inet6 fe80 :: b7f7: 2aa8: 7eeb: 1851/64 scope link
       valid_lft forever preferred_lft forever
3: enp4s6: <NO-CARRIER, BROADCAST, MULTICAST, UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link / ether 00: 00: e8: f9: 74: 75 brd ff: ff: ff: ff: ff: ff
7: lxcbr0: <BROADCAST, MULTICAST, UP, LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link / ether 00: 16: 3e: 00: 00: 00 brd ff: ff: ff: ff: ff: ff
    inet 192.168.3.10/24 global scope lxcbr0
       valid_lft forever preferred_lft forever
    inet6 fe80 :: 216: 3eff: fe00: 0/64 scope link
       valid_lft forever preferred_lft forever
11: vethGK5V9U @ if10: <BROADCAST, MULTICAST, UP, LOWER_UP> mtu 1500 qdisc noqueue master lxcbr0 state UP group default qlen 1000
    link / ether faith: ba: 8c: 8e: e6: a7 brd ff: ff: ff: ff: ff: ff link-netnsid 1
    inet6 fe80 :: fcba: 8cff: fe8e: e6a7 / 64 scope link
       valid_lft forever preferred_lft forever
13: veth520VLL @ if12: <BROADCAST, MULTICAST, UP, LOWER_UP> mtu 1500 qdisc noqueue master lxcbr0 state UP group default qlen 1000
    link / ether faith: 1f: b7: b4: 9e: f1 brd ff: ff: ff: ff: ff: ff link-netnsid 2
    inet6 fe80 :: fc1f: b7ff: feb4: 9ef1 / 64 scope link
       valid_lft forever preferred_lft forever
17: vethJ53IIC @ if16: <BROADCAST, MULTICAST, UP, LOWER_UP> mtu 1500 qdisc noqueue master lxcbr0 state UP group default qlen 1000
    link / ether faith: 50: b2: a9: 73: 52 brd ff: ff: ff: ff: ff: ff link-netnsid 0
    inet6 fe80 :: fc50: b2ff: fea9: 7352/64 scope link
       valid_lft forever preferred_lft forever

/ etc / network / interfaces

 This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces (5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto what
iface what inet loopback

#Inside of / etc / network / interfaces

auto lxcbr0
iface lxcbr0 inet static
        bridge_ports enp3s0
        address 192.168.0.30
        netmask 255.255.255.0
        gateway 192.168.0.90
        dns-nameservers 8.8.8.8 8.8.4.4

LXC container
/etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

#auto enp3s0
#iface enp3s0 inet dhcp

auto enp3s0
iface enp3s0 inet static
       address 192.168.3.240
       netmask 255.255.255.0
       gateway 192.168.0.90
      dns-nameservers 8.8.8.8

Are my configurations correct?
If more information is needed please let me know, I will answer as soon as possible, thank you very much


(Sergey Durnov) #2

You better not to use lxcbr for such config,
Use bridge-utils package and just create you own bridge.
Then runc lxc reconfig and choose to use your bridge.

If you have netplan in your system, check this: Lxd + Netplan + Static IP's in same subnet HOW-TO


(gery escalier) #3

thank you very much @sdurnov I’m documenting with https://wiki.debian.org/BridgeNetworkConnections comment if I have any questions.

Regards!!! :grinning::beers: