当前位置:   article > 正文

两个路由器不同网段,如何实现内网互通_不同网段的ip怎么互通

不同网段的ip怎么互通

我们经常会遇到企业随着员工或部门的增多,增加了一个路由器,分了两个网段,A子网和B子网处于不同网段,当网络中存在多个路由器时,要求不同路由器下属的子网可以互相通讯,同时又可以通过宽带路由器上网,这如何实现?

案例情景1
企业通过一台路由器R1上网,局域网LAN1。因为业务需要,扩充了一台路由器R2,加入一个新的局域网段LAN2。现在PC1与PC2都能正常访问外网,PC2可以访问 PC1,但是如何让PC1通访问PC2,网络拓扑图如下:

为了模拟真实的上网环境,我们先把网络部署一下。 

1、R1路由器设置 

  1. <R1>sys
  2. [R1]sys R1
  3. [R1]un in en
  4. [R1]dhcp enable
  5. [R1]int g0/0/0
  6. [R1-GigabitEthernet0/0/0]ip addr 192.168.137.10 24
  7. [R1-GigabitEthernet0/0/0]quit
  8. [R1]int g0/0/1
  9. [R1-GigabitEthernet0/0/1]ip addr 192.168.10.1 24
  10. [R1-GigabitEthernet0/0/1]dhcp select int
  11. [R1-GigabitEthernet0/0/1]dhcp server dns-list 114.114.114.114
  12. [R1-GigabitEthernet0/0/1]quit
  13. # NAT设置实现上网
  14. [R1]acl 2000
  15. [R1-acl-basic-2000]rule 5 permit source 192.168.10.0 0.0.0.255
  16. [R1-acl-basic-2000]int g0/0/0
  17. [R1-GigabitEthernet0/0/0]nat outbound 2000
  18. [R1-GigabitEthernet0/0/0]quit
  19. [R1]dns resolve
  20. [R1]dns server 114.114.114.114
  21. # 默认路由
  22. [R1]ip route-static 0.0.0.0 0.0.0.0 192.168.137.1

2、R2路由器设置

  1. <R2>sys
  2. [R2]sys R2
  3. [R2]un in en
  4. [R2]dhcp enable
  5. [R2]int g0/0/0
  6. [R2-GigabitEthernet0/0/0]ip addr 192.168.10.2 24
  7. [R2-GigabitEthernet0/0/0]quit
  8. [R2]int g0/0/1
  9. [R2-GigabitEthernet0/0/1]ip addr 10.0.10.254 24
  10. [R2-GigabitEthernet0/0/1]dhcp select int
  11. [R2-GigabitEthernet0/0/1]dhcp server dns-list 114.114.114.114
  12. [R2-GigabitEthernet0/0/1]quit
  13. # NAT设置实现上网
  14. [R2]acl 2000
  15. [R2-acl-basic-2000]rule 5 permit source 10.0.10.0 0.0.0.255
  16. [R2-acl-basic-2000]int g0/0/0
  17. [R2-GigabitEthernet0/0/0]nat outbound 2000
  18. [R2-GigabitEthernet0/0/0]quit
  19. [R2]dns resolve
  20. [R2]dns server 114.114.114.114
  21. # 默认路由
  22. [R2]ip route-static 0.0.0.0 0.0.0.0 192.168.10.1

3、通过上面设置我们已实现

PC1可以上网

  1. PC1>ping www.baidu.com
  2. www.baidu.com -> www.a.shifen.com
  3. Ping www.a.shifen.com [110.242.68.3]: 32 data bytes, Press Ctrl_C to break
  4. From 110.242.68.3: bytes=32 seq=1 ttl=45 time=62 ms
  5. From 110.242.68.3: bytes=32 seq=2 ttl=45 time=78 ms
  6. From 110.242.68.3: bytes=32 seq=3 ttl=45 time=78 ms
  7. From 110.242.68.3: bytes=32 seq=4 ttl=45 time=47 ms
  8. From 110.242.68.3: bytes=32 seq=5 ttl=45 time=63 ms
  9. --- 110.242.68.3 ping statistics ---
  10. 5 packet(s) transmitted
  11. 5 packet(s) received
  12. 0.00% packet loss
  13. round-trip min/avg/max = 47/65/78 ms

PC2可以上网

  1. PC2>ping www.baidu.com
  2. www.baidu.com -> www.a.shifen.com
  3. Ping www.a.shifen.com [110.242.68.3]: 32 data bytes, Press Ctrl_C to break
  4. From 110.242.68.3: bytes=32 seq=1 ttl=44 time=78 ms
  5. From 110.242.68.3: bytes=32 seq=2 ttl=44 time=62 ms
  6. From 110.242.68.3: bytes=32 seq=3 ttl=44 time=63 ms
  7. From 110.242.68.3: bytes=32 seq=4 ttl=44 time=78 ms
  8. From 110.242.68.3: bytes=32 seq=5 ttl=44 time=94 ms
  9. --- 110.242.68.3 ping statistics ---
  10. 5 packet(s) transmitted
  11. 5 packet(s) received
  12. 0.00% packet loss
  13. round-trip min/avg/max = 62/75/94 ms

PC2访问PC1

  1. PC2>ping 192.168.10.254
  2. Ping 192.168.10.254: 32 data bytes, Press Ctrl_C to break
  3. From 192.168.10.254: bytes=32 seq=1 ttl=127 time=32 ms
  4. From 192.168.10.254: bytes=32 seq=2 ttl=127 time=31 ms
  5. From 192.168.10.254: bytes=32 seq=3 ttl=127 time=47 ms
  6. From 192.168.10.254: bytes=32 seq=4 ttl=127 time=31 ms
  7. From 192.168.10.254: bytes=32 seq=5 ttl=127 time=47 ms
  8. --- 192.168.10.254 ping statistics ---
  9. 5 packet(s) transmitted
  10. 5 packet(s) received
  11. 0.00% packet loss
  12. round-trip min/avg/max = 31/37/47 ms

PC1不可以访问PC2

  1. PC>ping 10.0.10.253
  2. Ping 10.0.10.253: 32 data bytes, Press Ctrl_C to break
  3. Request timeout!
  4. Request timeout!
  5. Request timeout!
  6. Request timeout!
  7. Request timeout!
  8. --- 10.0.10.253 ping statistics ---
  9. 5 packet(s) transmitted
  10. 0 packet(s) received
  11. 100.00% packet loss

4、R1增加静态路由

  1. # 增加静态路由,实现10.0.10.0网段访问192.168.10.0
  2. [R1]ip route-static 10.0.10.0 24 192.168.10.2

PC1成功访问PC2 

  1. PC1>ping 10.0.10.253
  2. Ping 10.0.10.253: 32 data bytes, Press Ctrl_C to break
  3. From 10.0.10.253: bytes=32 seq=1 ttl=127 time=62 ms
  4. From 10.0.10.253: bytes=32 seq=2 ttl=127 time=63 ms
  5. From 10.0.10.253: bytes=32 seq=3 ttl=127 time=62 ms
  6. From 10.0.10.253: bytes=32 seq=4 ttl=127 time=63 ms
  7. From 10.0.10.253: bytes=32 seq=5 ttl=127 time=47 ms
  8. --- 10.0.10.253 ping statistics ---
  9. 5 packet(s) transmitted
  10. 5 packet(s) received
  11. 0.00% packet loss
  12. round-trip min/avg/max = 47/59/63 ms

如果你所在的网络还是不通,也可以在 R2路由器开启 "端口映射/转发" 功能

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/652698
推荐阅读
相关标签
  

闽ICP备14008679号