为多个 NIC 配置 iproute2 并验证

为多个 NIC 配置 iproute2 并验证

为了避免 CentOS 6 服务器具有多个 NIC 时出现路由分离,我正在配置 iproute2,以引导来自特定 NIC(VLAN)的流量仅通过该 NIC 返回,而不是通过服务器 eth0 上设置的默认路由。这就是现在的样子。

IP 地址

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:50:56:9b:1c:1d brd ff:ff:ff:ff:ff:ff
    inet 10.2.130.206/24 brd 10.2.130.255 scope global eth3
    inet6 fe80::250:56ff:fe9b:1c1d/64 scope link
       valid_lft forever preferred_lft forever
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:50:56:9b:6c:b3 brd ff:ff:ff:ff:ff:ff
    inet 10.2.220.206/24 brd 10.2.220.255 scope global eth0
    inet6 fe80::250:56ff:fe9b:6cb3/64 scope link
       valid_lft forever preferred_lft forever
4: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:50:56:9b:4b:b1 brd ff:ff:ff:ff:ff:ff
    inet 10.2.120.206/24 brd 10.2.120.255 scope global eth1
    inet6 fe80::250:56ff:fe9b:4bb1/64 scope link
       valid_lft forever preferred_lft forever
5: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:50:56:9b:4b:14 brd ff:ff:ff:ff:ff:ff
    inet 10.2.100.206/24 brd 10.2.100.255 scope global eth2
    inet6 fe80::250:56ff:fe9b:4b14/64 scope link
       valid_lft forever preferred_lft forever

路由

10.2.130.0/24 dev eth3  proto kernel  scope link  src 10.2.130.206
10.2.100.0/24 dev eth2  proto kernel  scope link  src 10.2.100.206
10.2.220.0/24 dev eth0  proto kernel  scope link  src 10.2.220.206
10.2.120.0/24 dev eth1  proto kernel  scope link  src 10.2.120.206
169.254.0.0/16 dev eth3  scope link  metric 1002
169.254.0.0/16 dev eth0  scope link  metric 1003
169.254.0.0/16 dev eth1  scope link  metric 1004
169.254.0.0/16 dev eth2  scope link  metric 1005
default via 10.2.220.1 dev eth0

ip 规则

0:      from all lookup local
32762:  from 10.2.130.0/24 lookup development
32763:  from 10.2.100.0/24 lookup protected
32764:  from 10.2.120.0/24 lookup external
32765:  from 10.2.220.0/24 lookup management
32766:  from all lookup main
32767:  from all lookup default

现在一切“似乎”都按预期进行,但我该如何实际验证这一点?

答案1

我该如何验证这一点

运行 tcpdump/wireshark,使用特定接口-i interface并生成一些流量,这些流量应该通过特定接口,使用您最喜欢的工具。Netcat 到 tcp 服务可能是一个不错的选择。确保您看到连接的所有内容,使用 tcp,确保您看到 3 次握手的两个方向,以及连接关闭的所有数据包。

相关内容