用GNS3和主机搭建一个实验环境来验证单网卡多IP多路由的可行性<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
实验环境:
拓扑如下 :
两台PC机其实是同一台主机是的同一张网卡,只不过这张网卡配上三个IP,两个网关
这样一台PC的IP相当于网卡里面的一个IP
两台PC:
一台的IP:192.168.2.1/24
另一台的IP:192.168.3.1/24
路由器:有两个接口:
一个IP:192.168.2.2
另一个IP:192.168.3.2
.
配置如下:
1.路由器的配置:
r0(config-if)#ip add 192.168.2.2 255.255.255.0
r0(config-if)#no sh
r0(config-if)#exit
r0(config)#int s1/
*Mar 1 00:03:24.143: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar 1 00:03:25.143: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
r0(config)#int f1/0
r0(config-if)#ip add 192.168.3.2
% Incomplete command.
r0(config-if)#ip add 192.168.3.2 255.255.255.0
r0(config-if)#no sh
r0(config-if)#
*Mar 1 00:03:50.399: %LINK-3-UPDOWN: Interface FastEthernet1/0, changed state to up
*Mar 1 00:03:51.399: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up
r0(config-if)#do ping 192.168.2.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />1/24/68 ms
r0(config-if)#do ping 192.168.3.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/20/36 ms
r0(config-if)#
以上用路由器来PING主机成功代表实验已经做成功,说明单网卡配置多个IP多个网关是完全可以的
2.PC机的配置:
3.GNS的搭建:
注:全部增加主机上的网卡。
4.在本机上测试用
用IPCONFIG/ALL查看IP的具体配置:
PC1ping R0的f1/0的IP,
PC0ping R0的f1/0的IP
如图:
转载于:https://blog.51cto.com/gauyanm/241105