Linuxを使用したブリッジネットワーク

Linuxを使用したブリッジネットワーク

私はLinuxネットワークとブリッジを理解し、ブリッジを使用してネットワークを設定しようとしています。 eth0インターフェイスを使用する2つの仮想マシンがあります

仮想マシン A -> 10.0.1.7(eth0)

仮想マシン B -> 10.0.1.8(eth0)

次の追加ルート(10.0.1.1)で構成されたルーター

対象: 10.1.7.0/24, ネクストホップ = 10.0.1.7

対象: 10.1.8.0/24, ネクストホップ = 10.0.1.8

次のコマンドを使用してLinuxブリッジを追加しました。

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

eth0 インターフェイスの VM A から VM A への Ping 要求

[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

VM A から VM A への Ping 要求が br0 インターフェイスで失敗する

[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

VM Bで10.1.7.1をpingしようとすると、VM Aはエコー応答を送信していますが、VM bはそれを受け取りません。

[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

両方の仮想マシンのiptablesが更新され、tcpdumpは次のようになります。

仮想マシン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 

仮想マシン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

br0インターフェイスのtcpdumpを実行すると(tcpdump -i br0 icmp)、パケットは表示されません。なぜですか? 10.1.7.1はbr0に添付されています。

iptables設定が必要ですか?

eth0をbr0に接続しようとしました。 (brctl addif br0 eth0)VM接続が失われ、VMをsshまたはpingできません。 eth0インターフェイスがパケットをbr0に転送する他の方法はありますか?私はvethやtuntapインターフェースに興味がありません。そうですか?

ベストアンサー1

おすすめ記事