某天发现一台CentOS机器网络一切正常, 但是却无法正常上网. 后经查询, 发现该机器的网关mac地址与实际网关的mac地址不符. 下面是查看和解决办法.
查看arp
$ cat /proc/net/arp IP address HW type Flags HW address Mask Device 192.168.43.62 0x1 0x2 24:6e:96:93:c9:7d * eth0 192.168.43.61 0x1 0x2 24:6e:96:8c:e0:65 * eth0 192.168.43.154 0x1 0x0 00:00:00:00:00:00 * eth0 192.168.43.153 0x1 0x2 52:54:00:fa:bb:fc * eth0 192.168.43.60 0x1 0x0 00:00:00:00:00:00 * eth0 192.168.43.59 0x1 0x0 00:00:00:00:00:00 * eth0 192.168.43.151 0x1 0x2 52:54:00:aa:73:e2 * eth0 192.168.43.11 0x1 0x0 00:00:00:00:00:00 * eth0 192.168.43.31 0x1 0x2 00:be:75:c7:47:ea * eth0 192.168.43.111 0x1 0x0 00:00:00:00:00:00 * eth0 192.168.43.27 0x1 0x2 52:54:00:b4:3f:a3 * eth0 192.168.43.224 0x1 0x0 00:00:00:00:00:00 * eth0 192.168.43.26 0x1 0x2 52:54:00:33:50:7e * eth0 192.168.43.223 0x1 0x0 00:00:00:00:00:00 * eth0 192.168.43.25 0x1 0x2 52:54:00:b4:3f:a3 * eth0 192.168.43.1 0x1 0x2 3c:f5:cc:91:79:87 * eth0 192.168.43.163 0x1 0x2 52:54:00:78:13:7d * eth0 192.168.43.162 0x1 0x2 52:54:00:7f:83:a4 * eth0 192.168.43.104 0x1 0x2 52:54:00:34:0c:fc * eth0 192.168.43.21 0x1 0x0 00:00:00:00:00:00 * eth0 192.168.43.44 0x1 0x2 24:6e:96:93:a3:c4 * eth0 192.168.43.43 0x1 0x2 24:6e:96:8c:df:64 * eth0 192.168.43.158 0x1 0x2 52:54:00:9a:ff:9f * eth0 192.168.43.122 0x1 0x2 52:54:00:99:e5:5e * eth0 $ arp -a ? (192.168.43.62) at 24:6e:96:93:c9:7d [ether] on eth0 ? (192.168.43.61) at 24:6e:96:8c:e0:65 [ether] on eth0 ? (192.168.43.154) at <incomplete> on eth0 ? (192.168.43.153) at 52:54:00:fa:bb:fc [ether] on eth0 ? (192.168.43.60) at <incomplete> on eth0 ? (192.168.43.59) at <incomplete> on eth0 ? (192.168.43.151) at 52:54:00:aa:73:e2 [ether] on eth0 ? (192.168.43.11) at <incomplete> on eth0 ? (192.168.43.31) at 00:be:75:c7:47:ea [ether] on eth0 ? (192.168.43.111) at <incomplete> on eth0 ? (192.168.43.27) at 52:54:00:b4:3f:a3 [ether] on eth0 ? (192.168.43.224) at <incomplete> on eth0 ? (192.168.43.26) at 52:54:00:33:50:7e [ether] on eth0 ? (192.168.43.223) at <incomplete> on eth0 ? (192.168.43.25) at 52:54:00:b4:3f:a3 [ether] on eth0 gateway (192.168.43.1) at 3c:f5:cc:91:79:87 [ether] on eth0 ? (192.168.43.163) at 52:54:00:78:13:7d [ether] on eth0 ? (192.168.43.162) at 52:54:00:7f:83:a4 [ether] on eth0 ? (192.168.43.104) at 52:54:00:34:0c:fc [ether] on eth0 ? (192.168.43.21) at <incomplete> on eth0 ? (192.168.43.44) at 24:6e:96:93:a3:c4 [ether] on eth0 ? (192.168.43.43) at 24:6e:96:8c:df:64 [ether] on eth0 ? (192.168.43.158) at 52:54:00:9a:ff:9f [ether] on eth0
绑定arp
绑定arp的过程在某些国外网站称之为Create a Static ARP Table. 下面演示手动绑定网关192.168.43.1的mac地址为74:ea:c8:2d:9f:f6
arp -s 192.168.43.1 74:ea:c8:2d:9f:f6