赞
踩
我们经常会遇到企业随着员工或部门的增多,增加了一个路由器,分了两个网段,A子网和B子网处于不同网段,当网络中存在多个路由器时,要求不同路由器下属的子网可以互相通讯,同时又可以通过宽带路由器上网,这如何实现?
案例情景1
企业通过一台路由器R1上网,局域网LAN1。因为业务需要,扩充了一台路由器R2,加入一个新的局域网段LAN2。现在PC1与PC2都能正常访问外网,PC2可以访问 PC1,但是如何让PC1通访问PC2,网络拓扑图如下:
为了模拟真实的上网环境,我们先把网络部署一下。
1、R1路由器设置
- <R1>sys
- [R1]sys R1
- [R1]un in en
-
- [R1]dhcp enable
-
- [R1]int g0/0/0
- [R1-GigabitEthernet0/0/0]ip addr 192.168.137.10 24
- [R1-GigabitEthernet0/0/0]quit
-
- [R1]int g0/0/1
- [R1-GigabitEthernet0/0/1]ip addr 192.168.10.1 24
- [R1-GigabitEthernet0/0/1]dhcp select int
- [R1-GigabitEthernet0/0/1]dhcp server dns-list 114.114.114.114
- [R1-GigabitEthernet0/0/1]quit
-
- # NAT设置实现上网
- [R1]acl 2000
- [R1-acl-basic-2000]rule 5 permit source 192.168.10.0 0.0.0.255
- [R1-acl-basic-2000]int g0/0/0
- [R1-GigabitEthernet0/0/0]nat outbound 2000
- [R1-GigabitEthernet0/0/0]quit
-
- [R1]dns resolve
- [R1]dns server 114.114.114.114
-
- # 默认路由
- [R1]ip route-static 0.0.0.0 0.0.0.0 192.168.137.1
2、R2路由器设置
- <R2>sys
- [R2]sys R2
- [R2]un in en
-
- [R2]dhcp enable
-
- [R2]int g0/0/0
- [R2-GigabitEthernet0/0/0]ip addr 192.168.10.2 24
- [R2-GigabitEthernet0/0/0]quit
-
- [R2]int g0/0/1
- [R2-GigabitEthernet0/0/1]ip addr 10.0.10.254 24
- [R2-GigabitEthernet0/0/1]dhcp select int
- [R2-GigabitEthernet0/0/1]dhcp server dns-list 114.114.114.114
- [R2-GigabitEthernet0/0/1]quit
-
- # NAT设置实现上网
- [R2]acl 2000
- [R2-acl-basic-2000]rule 5 permit source 10.0.10.0 0.0.0.255
- [R2-acl-basic-2000]int g0/0/0
- [R2-GigabitEthernet0/0/0]nat outbound 2000
- [R2-GigabitEthernet0/0/0]quit
-
- [R2]dns resolve
- [R2]dns server 114.114.114.114
-
- # 默认路由
- [R2]ip route-static 0.0.0.0 0.0.0.0 192.168.10.1
3、通过上面设置我们已实现
PC1可以上网
- PC1>ping www.baidu.com
-
- www.baidu.com -> www.a.shifen.com
-
- Ping www.a.shifen.com [110.242.68.3]: 32 data bytes, Press Ctrl_C to break
- From 110.242.68.3: bytes=32 seq=1 ttl=45 time=62 ms
- From 110.242.68.3: bytes=32 seq=2 ttl=45 time=78 ms
- From 110.242.68.3: bytes=32 seq=3 ttl=45 time=78 ms
- From 110.242.68.3: bytes=32 seq=4 ttl=45 time=47 ms
- From 110.242.68.3: bytes=32 seq=5 ttl=45 time=63 ms
-
- --- 110.242.68.3 ping statistics ---
- 5 packet(s) transmitted
- 5 packet(s) received
- 0.00% packet loss
- round-trip min/avg/max = 47/65/78 ms
PC2可以上网
- PC2>ping www.baidu.com
-
- www.baidu.com -> www.a.shifen.com
-
- Ping www.a.shifen.com [110.242.68.3]: 32 data bytes, Press Ctrl_C to break
- From 110.242.68.3: bytes=32 seq=1 ttl=44 time=78 ms
- From 110.242.68.3: bytes=32 seq=2 ttl=44 time=62 ms
- From 110.242.68.3: bytes=32 seq=3 ttl=44 time=63 ms
- From 110.242.68.3: bytes=32 seq=4 ttl=44 time=78 ms
- From 110.242.68.3: bytes=32 seq=5 ttl=44 time=94 ms
-
- --- 110.242.68.3 ping statistics ---
- 5 packet(s) transmitted
- 5 packet(s) received
- 0.00% packet loss
- round-trip min/avg/max = 62/75/94 ms
PC2访问PC1
- PC2>ping 192.168.10.254
-
- Ping 192.168.10.254: 32 data bytes, Press Ctrl_C to break
- From 192.168.10.254: bytes=32 seq=1 ttl=127 time=32 ms
- From 192.168.10.254: bytes=32 seq=2 ttl=127 time=31 ms
- From 192.168.10.254: bytes=32 seq=3 ttl=127 time=47 ms
- From 192.168.10.254: bytes=32 seq=4 ttl=127 time=31 ms
- From 192.168.10.254: bytes=32 seq=5 ttl=127 time=47 ms
-
- --- 192.168.10.254 ping statistics ---
- 5 packet(s) transmitted
- 5 packet(s) received
- 0.00% packet loss
- round-trip min/avg/max = 31/37/47 ms
PC1不可以访问PC2
- PC>ping 10.0.10.253
-
- Ping 10.0.10.253: 32 data bytes, Press Ctrl_C to break
- Request timeout!
- Request timeout!
- Request timeout!
- Request timeout!
- Request timeout!
-
- --- 10.0.10.253 ping statistics ---
- 5 packet(s) transmitted
- 0 packet(s) received
- 100.00% packet loss
4、R1增加静态路由
- # 增加静态路由,实现10.0.10.0网段访问192.168.10.0
- [R1]ip route-static 10.0.10.0 24 192.168.10.2
PC1成功访问PC2
- PC1>ping 10.0.10.253
-
- Ping 10.0.10.253: 32 data bytes, Press Ctrl_C to break
- From 10.0.10.253: bytes=32 seq=1 ttl=127 time=62 ms
- From 10.0.10.253: bytes=32 seq=2 ttl=127 time=63 ms
- From 10.0.10.253: bytes=32 seq=3 ttl=127 time=62 ms
- From 10.0.10.253: bytes=32 seq=4 ttl=127 time=63 ms
- From 10.0.10.253: bytes=32 seq=5 ttl=127 time=47 ms
-
- --- 10.0.10.253 ping statistics ---
- 5 packet(s) transmitted
- 5 packet(s) received
- 0.00% packet loss
- round-trip min/avg/max = 47/59/63 ms
如果你所在的网络还是不通,也可以在 R2路由器开启 "端口映射/转发" 功能
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。