3月 112013
 

本机PING互联网主机显示网络已连通

[root@localhost ~]# ping www.qq.com -c 5
 PING www.qq.com (119.147.15.17) 56(84) bytes of data.
 64 bytes from 119.147.15.17: icmp_seq=1 ttl=55 time=1.84 ms
 64 bytes from 119.147.15.17: icmp_seq=2 ttl=55 time=2.23 ms
 64 bytes from 119.147.15.17: icmp_seq=3 ttl=55 time=2.03 ms
 64 bytes from 119.147.15.17: icmp_seq=4 ttl=55 time=2.19 ms
 64 bytes from 119.147.15.17: icmp_seq=5 ttl=55 time=2.06 ms
--- www.qq.com ping statistics ---
 5 packets transmitted, 5 received, 0% packet loss, time 4007ms
 rtt min/avg/max/mdev = 1.843/2.075/2.234/0.143 ms
 [root@localhost ~]#

通过其他主机分别ping双网卡的两个接口IP地址

linux-nic-route-01

linux-nic-route-02

查看主机网络接口配置信息

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
 DEVICE="eth0"
 BOOTPROTO="static"
 HWADDR="00:50:56:A8:1D:55"
 NM_CONTROLLED="yes"
 ONBOOT="yes"
 TYPE="Ethernet"
 UUID="2bfc3a4e-e6e9-4022-a318-d6033b349e9c"
 IPADDR=192.168.11.150
 PREFIX=24
 GATEWAY=192.168.11.1
 DNS1=202.96.128.86
 [root@localhost ~]#
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
 DEVICE="eth1"
 BOOTPROTO="static"
 HWADDR="00:50:56:A8:1D:56"
 NM_CONTROLLED="yes"
 ONBOOT="yes"
 TYPE="Ethernet"
 UUID="3bed83c9-d166-43a0-b6dd-70b4897551a4"
 IPADDR=192.168.21.150
 PREFIX=24
 GATEWAY=192.168.21.1
 DNS1=202.96.128.86
 [root@localhost ~]#

添加路由信息

为每个接口指定默认路由

[root@localhost ~]# ip route replace default via 192.168.11.1 dev eth0
 [root@localhost ~]# ip route replace default via 192.168.21.1 dev eth1

添加路由表

# ip route add 192.168.11.0/24 dev eth0 src 192.168.11.150 table 200
# ip route add default via 192.168.11.1 table 200
# ip route add 192.168.21.0/24 dev eth1 src 192.168.21.150 table 201
# ip route add default via 192.168.21.1 table 201

设置路由表规则

[root@localhost ~]# ip rule add from 192.168.11.150 table 200
 [root@localhost ~]# ip rule add from 192.168.21.150 table 201

再次PING目的主机网络eth0接口

linux-nic-route-03

实验网络拓扑

linux-nic-route-03

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据