Eu tenho 2 máquinas de virtualboxes (geradas pelo Vagrant). Em cada uma dessas máquinas existem 2 recipientes lxc. Tenho comunicação entre máquinas de caixa virtual e também tenho comunicação entre contêineres lxc, mas apenas dentro da mesma máquina virtualbox. O que precisa arquivar é ter comunicação entre todos os contêineres LXC .
Eu tenho praticamente configurações de rede padrão em máquinas vbox e lxc Vagrant.
A rede do Vagrant para configurações do vmboxex é:
m1dca.vm.network "private_network", ip: "192.168.12.10", netmask: "255.255.255.0"
m2dca.vm.network "private_network", ip: "192.168.12.10", netmask: "255.255.255.0"
Os contaners LXC têm configurações:
# Network configuration
lxc.network.type = veth
lxc.network.link = lxcbr0
lxc.network.flags = up
lxc.network.hwaddr = 00:16:3e:a6:98:72
Configurações de IP da máquina Virtualbox1:
vagrant@m1dca:~$ sudo lxc-ls --fancy
NAME STATE AUTOSTART GROUPS IPV4 IPV6
mv1 RUNNING 0 - 10.0.3.81 -
mv2 RUNNING 0 - 10.0.3.60 -
vagrant@m1dca:~$ ip a
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 lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 02:38:07:4c:82:85 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global enp0s3
valid_lft forever preferred_lft forever
inet6 fe80::38:7ff:fe4c:8285/64 scope link
valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:51:19:03 brd ff:ff:ff:ff:ff:ff
inet 192.168.12.10/24 brd 192.168.12.255 scope global enp0s8
valid_lft forever preferred_lft forever
4: lxcbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 00:16:3e:00:00:00 brd ff:ff:ff:ff:ff:ff
inet 10.0.3.1/24 scope global lxcbr0
valid_lft forever preferred_lft forever
vagrant@m1dca:~$ ip r
default via 10.0.2.2 dev enp0s3
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15
10.0.3.0/24 dev lxcbr0 proto kernel scope link src 10.0.3.1
192.168.12.0/24 dev enp0s8 proto kernel scope link src 192.168.12.10
Configurações de IP do contêiner MV1
root@mv1:/# ip a
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 lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
5: eth0@if6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:16:3e:77:5d:cc brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.0.3.81/24 brd 10.0.3.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::216:3eff:fe77:5dcc/64 scope link
valid_lft forever preferred_lft forever
root@mv1:/# ip r
default via 10.0.3.1 dev eth0
10.0.3.0/24 dev eth0 proto kernel scope link src 10.0.3.81
Configurações de IP do contêiner MV2
root@mv2:/# ip a
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 lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
7: eth0@if8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:16:3e:db:87:9c brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.0.3.60/24 brd 10.0.3.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::216:3eff:fedb:879c/64 scope link
valid_lft forever preferred_lft forever
root@mv2:/# ip r
default via 10.0.3.1 dev eth0
10.0.3.0/24 dev eth0 proto kernel scope link src 10.0.3.60
Configurações de IP da máquina do Virtualbox2:
vagrant@m2dca:~$ sudo lxc-ls --fancy
NAME STATE AUTOSTART GROUPS IPV4 IPV6
mv4 RUNNING 0 - 10.0.3.247 -
vm3 RUNNING 0 - 10.0.3.150 -
vagrant@m2dca:~$ ip a
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 lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 02:38:07:4c:82:85 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global enp0s3
valid_lft forever preferred_lft forever
inet6 fe80::38:7ff:fe4c:8285/64 scope link
valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:9f:02:d3 brd ff:ff:ff:ff:ff:ff
inet 192.168.12.11/24 brd 192.168.12.255 scope global enp0s8
valid_lft forever preferred_lft forever
4: 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 10.0.3.1/24 scope global lxcbr0
valid_lft forever preferred_lft forever
inet6 fe80::216:3eff:fe00:0/64 scope link
valid_lft forever preferred_lft forever
6: veth9PTJVP@if5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master lxcbr0 state UP group default qlen 1000
link/ether fe:b3:d3:80:8b:eb brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet6 fe80::fcb3:d3ff:fe80:8beb/64 scope link
valid_lft forever preferred_lft forever
8: vethRY5WTV@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master lxcbr0 state UP group default qlen 1000
link/ether fe:8e:85:82:de:25 brd ff:ff:ff:ff:ff:ff link-netnsid 1
inet6 fe80::fc8e:85ff:fe82:de25/64 scope link
valid_lft forever preferred_lft forever
vagrant@m2dca:~$ ip r
default via 10.0.2.2 dev enp0s3
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15
10.0.3.0/24 dev lxcbr0 proto kernel scope link src 10.0.3.1
192.168.12.0/24 dev enp0s8 proto kernel scope link src 192.168.12.11
Configurações de IP do contêiner MV3:
root@vm3:/# ip a
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 lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
5: eth0@if6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:16:3e:a6:98:72 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.0.3.150/24 brd 10.0.3.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::216:3eff:fea6:9872/64 scope link
valid_lft forever preferred_lft forever
root@vm3:/# ip r
default via 10.0.3.1 dev eth0
10.0.3.0/24 dev eth0 proto kernel scope link src 10.0.3.150
Configurações de IP do contêiner MV4 :
root@mv4:/# ip a
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 lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
7: eth0@if8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:16:3e:17:77:4b brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.0.3.247/24 brd 10.0.3.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::216:3eff:fe17:774b/64 scope link
valid_lft forever preferred_lft forever
root@mv4:/# ip r
default via 10.0.3.1 dev eth0
10.0.3.0/24 dev eth0 proto kernel scope link src 10.0.3.247
Tags networking virtualbox vagrant lxc