1

I am trying understand Linux networking and bridges, setting a network using bridges. I have two VMs with eth0 interfaces

VM A -> 10.0.1.7 (eth0)

VM B -> 10.0.1.8 (eth0)

Router (10.0.1.1 ) which is confiured with below additional routes

destination: 10.1.7.0/24 , nexthop = 10.0.1.7

destination: 10.1.8.0/24, nexthop = 10.0.1.8

I have added a Linux bridge with following commands

ip link add br0 type bridge
ip addr add 10.1.7.1/24 dev br0
ip link set br0 up

[root@test-1 centos]# ip addr
1: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether fa:16:3e:d9:59:5b brd ff:ff:ff:ff:ff:ff
inet 10.0.1.7/24 brd 10.0.1.255 scope global dynamic eth0
   valid_lft 507sec preferred_lft 507sec
inet6 fe80::f816:3eff:fed9:595b/64 scope link
   valid_lft forever preferred_lft forever
2: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN qlen 1000
link/ether 46:d0:ca:31:fa:b2 brd ff:ff:ff:ff:ff:ff
inet 10.1.7.1/24 scope global br0
   valid_lft forever preferred_lft forever
inet6 fe80::44d0:caff:fe31:fab2/64 scope link
   valid_lft forever preferred_lft forever

[root@test-1 centos]# ip route
default via 10.0.1.1 dev eth0
10.0.0.0/24 dev eth0  proto static  scope link
10.0.1.0/24 dev eth0  proto kernel  scope link  src 10.0.1.7
10.1.7.0/24 dev br0  proto kernel  scope link  src 10.1.7.1
169.254.169.254 via 10.0.1.1 dev eth0  proto static
172.16.60.0/24 dev eth0  proto static  scope link

Ping request from VM A to VM A on eth0 interface

[root@test-1 centos]# ping 10.1.7.1 -c 1
 PING 10.1.7.1 (10.1.7.1) 56(84) bytes of data.
 64 bytes from 10.1.7.1: icmp_seq=1 ttl=64 time=0.065 ms
 --- 10.1.7.1 ping statistics ---
 1 packets transmitted, 1 received, 0% packet loss, time 0ms
 rtt min/avg/max/mdev = 0.065/0.065/0.065/0.000 ms

Ping request from VM A to VM A on br0 interface is failing

[root@test-1 centos]# ping -I br0 10.1.7.1 -c 1
PING 10.1.7.1 (10.1.7.1) from 10.1.7.1 br0: 56(84) bytes of data.

--- 10.1.7.1 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms

Now when try to ping 10.1.7.1 from VM B, VM A is sending echo reply but VM b is not receiving it.

[root@test-2 centos]# ping 10.1.7.1 -c 2
PING 10.1.7.1 (10.1.7.1) 56(84) bytes of data.
--- 10.1.7.1 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 999ms

both VMs iptables are Flushed and tcpdump is below

VM A

[root@test-1 centos]# tcpdump -i eth0 -nn -t -vv icmp
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
IP (tos 0x0, ttl 63, id 16561, offset 0, flags [DF], proto ICMP (1), length 84)
    10.0.1.8 > 10.1.7.1: ICMP echo request, id 2660, seq 1, length 64
IP (tos 0x0, ttl 64, id 11195, offset 0, flags [none], proto ICMP (1), length 84)
    10.1.7.1 > 10.0.1.8: ICMP echo reply, id 2660, seq 1, length 64   
IP (tos 0x0, ttl 63, id 17282, offset 0, flags [DF], proto ICMP (1), length 84)
    10.0.1.8 > 10.1.7.1: ICMP echo request, id 2660, seq 2, length 64
IP (tos 0x0, ttl 64, id 11473, offset 0, flags [none], proto ICMP (1), length 84)
    10.1.7.1 > 10.0.1.8: ICMP echo reply, id 2660, seq 2, length 64 

VM B

[root@test-2 centos]# tcpdump -i eth0 -t -nn -vv icmp
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
IP (tos 0x0, ttl 64, id 16561, offset 0, flags [DF], proto ICMP (1), length 84)
    10.0.1.8 > 10.1.7.1: ICMP echo request, id 2660, seq 1, length 64
IP (tos 0x0, ttl 64, id 17282, offset 0, flags [DF], proto ICMP (1), length 84)
    10.0.1.8 > 10.1.7.1: ICMP echo request, id 2660, seq 2, length 64

And if I take a tcpdump of br0 interface (tcpdump -i br0 icmp), I am not seeing any packets - why? 10.1.7.1 is attached to br0.

Any iptables configuration required?

And I tried attaching eth0 to br0, ( brctl addif br0 eth0 ) I lose my vm connectivity and am not able to ssh or ping VM. Is there another way can eth0 interface forwards the packets to br0? I don't about about veth or tuntap interface; is that the way to do it?

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.