ubuntu18.04多网卡设置网桥后ping异常

包含网卡/无线网的网络问题和ADSL/校园网/宽带拨号支持及代理/共享等网络使用问题
回复
askkkkk
帖子: 14
注册时间: 2019-10-10 9:53
系统: ubuntu

ubuntu18.04多网卡设置网桥后ping异常

#1

帖子 askkkkk » 2021-01-07 18:54

ubuntu18.04系统,共有4个网卡,其中一个网卡是dhcp连接到路由器,另外三个桥接组成网桥,网桥用于接其他设备,与路由器是物理隔离的。
现在用另一个接在路由器上的电脑ping这台ubuntu机器,可以同时ping通 它dhcp分配的ip和网桥设置的ip,请问这是什么原理,为甚会两个同时通?
是不是因为两个网络有重叠导致的?

网桥是通过/etc/network/interfaces设置的

代码: 全选

root@xxxx:~# cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto enp4s0
iface enp4s0 inet dhcp

auto br0
iface br0 inet static
address 192.168.1.67
netmask 255.255.255.0
bridge_ports enp1s0 enp2s0 enp3s0
bridge_stp on

代码: 全选

root@xxxx:~# ifconfig
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.67  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::202:a0ff:fe00:1093  prefixlen 64  scopeid 0x20<link>
        ether 00:02:a0:00:10:93  txqueuelen 1000  (Ethernet)
        RX packets 11682  bytes 136370306 (136.3 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10370  bytes 916239 (916.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 00:02:a0:00:10:93  txqueuelen 1000  (Ethernet)
        RX packets 430717  bytes 164197461 (164.1 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2513125  bytes 3691381423 (3.6 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xd0900000-d091ffff

enp2s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 00:02:a0:00:af:d5  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xd0800000-d081ffff

enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 00:02:a0:00:10:94  txqueuelen 1000  (Ethernet)
        RX packets 2502130  bytes 3690440033 (3.6 GB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 339365  bytes 22333538 (22.3 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xd0700000-d071ffff

enp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.5.225  netmask 255.255.248.0  broadcast 192.168.7.255
        inet6 fe80::202:a0ff:fe00:afd4  prefixlen 64  scopeid 0x20<link>
        ether 00:02:a0:00:af:d4  txqueuelen 1000  (Ethernet)
        RX packets 662056  bytes 89847456 (89.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 103221  bytes 21108491 (21.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xd0600000-d061ffff

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 149503  bytes 46187651 (46.1 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 149503  bytes 46187651 (46.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

代码: 全选

root@xxxx:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 enp4s0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 enp4s0
192.168.0.0     0.0.0.0         255.255.248.0   U     0      0        0 enp4s0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 br0
askkkkk
帖子: 14
注册时间: 2019-10-10 9:53
系统: ubuntu

Re: ubuntu18.04多网卡设置网桥后ping异常

#2

帖子 askkkkk » 2021-01-08 11:25

找到解决办法了
net.ipv4.conf.all.arp_ignore = 1
头像
astolia
论坛版主
帖子: 6514
注册时间: 2008-09-18 13:11

Re: ubuntu18.04多网卡设置网桥后ping异常

#3

帖子 astolia » 2021-01-08 11:41

建议你还是把网段重叠问题处理一下,要不然按路由规则往192.168.1.x的包也可能从enp4s0发出去
回复