詳解不同網段(VLAN)通過靜態路由實現互通


詳解不同網段(VLAN)通過靜態路由實現互通

組網要求:某公司有三台屬於不同網段(Vlan)的主機通過三台交換機相連,要求不配置動態路由協議,使不同網段的任意兩台主機之間能夠互通。

一、本節主要知識點:

靜態路由:靜態路由是一種需要管理員手工配置的特殊路由。靜態路由比動態路由使用更少的帶寬,並且不占用CPU資源來計算和分析路由更新。但是當網絡發生故障或者拓撲發生變化后,靜態路由不會自動更新,必須手動重新配置。靜態路由有5個主要的參數:目的地址和掩碼、出接口和下一跳、優先級。

使用靜態路由的好處是配置簡單、可控性高,當網絡結構比較簡單時,只需配置靜態路由就可以使網絡正常工作。在復雜網絡環境中,還可以通過配置靜態路由改進網絡的性能,並且可以為重要的應用保證帶寬。

注意事項:一般情況下兩個設備之間的通信是雙向的,因此路由也必須是雙向的,在本端配置完靜態路由以后,請不要忘記在對端設備上配置回程路由。

在企業網絡雙出口的場景中,通過配置兩條等價的靜態路由可以實現負載分擔,流量可以均衡的分配到兩條不同的鏈路上;通過配置兩條不等價的靜態路由可以實現主備份,當主用鏈路故障的時候流量切換到備用鏈路上。

二、配置思路:

1. 創建VLAN並配置各接口所屬VLAN,配置各VLANIF接口的IP地址,實現相鄰設備

網絡互通。

2. 在各主機上配置IP缺省網關,在各台Switch上配置IPv4靜態路由或者靜態缺省路由,實現不配置動態路由協議,使不同網段的任意兩台主機之間能夠互通。

、IP設置:

1、SW1:VLANif10:192.168.10.254/24 ,vlan10

VLANif20:192.168.20.1/24 ,vlan20

PC1:192.168.10.1/24

2、SW2:VLANif20:192.168.20.2/24

VLANif30:192.168.30.254/24 ,vlan30

VLANif40:192.168.40.1/24

PC2:192.168.30.1/24

3、SW3:VLANif40:192.168.40.2/24

VLANif50:192.168.50.254/24 ,vlan 50

PC3:192.168.50.1/24

五、SW1交換機的主要配置文件:

#

sysname SW1

#

vlan batch 10 20

#

interface Vlanif10

ip address 192.168.10.254 255.255.255.0

#

interface Vlanif20

ip address 192.168.20.1 255.255.255.0

#

interface MEth0/0/1

#

interface GigabitEthernet0/0/1

port link-type access

port default vlan 10

#

interface GigabitEthernet0/0/2

port link-type trunk

port trunk allow-pass vlan 2 to 4094

#

ip route-static 0.0.0.0 0.0.0.0 192.168.20.2

#

return

六、SW2交換機的主要配置文件:

#

sysname SW2

#

vlan batch 20 30 40

#

interface Vlanif20

ip address 192.168.20.2 255.255.255.0

#

interface Vlanif30

ip address 192.168.30.254 255.255.255.0

#

interface Vlanif40

ip address 192.168.40.1 255.255.255.0

#

interface MEth0/0/1

#

interface GigabitEthernet0/0/1

port link-type trunk

port trunk allow-pass vlan 2 to 4094

#

interface GigabitEthernet0/0/2

port link-type trunk

port trunk allow-pass vlan 2 to 4094

#

interface GigabitEthernet0/0/3

port link-type access

port default vlan 30

#

ip route-static 192.168.10.0 255.255.255.0 192.168.20.1

ip route-static 192.168.50.0 255.255.255.0 192.168.40.2

#

return

七、SW3交換機的主要配置文件:

#

sysname SW3

#

vlan batch 40 50

#

interface Vlanif40

ip address 192.168.40.2 255.255.255.0

#

interface Vlanif50

ip address 192.168.50.254 255.255.255.0

#

interface MEth0/0/1

#

interface GigabitEthernet0/0/1

port link-type access

port default vlan 50

#

interface GigabitEthernet0/0/2

port link-type trunk

port trunk allow-pass vlan 2 to 4094

#

ip route-static 0.0.0.0 0.0.0.0 192.168.40.1

#

return

、驗證配置結果:

1、查看SW1的IP路由表。

[SW1]disp ip routing-table

Route Flags: R - relay, D - download to fib

------------------------------------------------------------------------------

Routing Tables: Public

Destinations : 7 Routes : 7

Destination/Mask Proto Pre Cost Flags NextHop Interface

0.0.0.0/0 Static 60 0 RD 192.168.20.2 Vlanif20

127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0

127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0

192.168.10.0/24 Direct 0 0 D 192.168.10.254 Vlanif10

192.168.10.254/32 Direct 0 0 D 127.0.0.1 Vlanif10

192.168.20.0/24 Direct 0 0 D 192.168.20.1 Vlanif20

192.168.20.1/32 Direct 0 0 D 127.0.0.1

2、查看SW2的IP路由表。

[SW2]disp ip routing-table

Route Flags: R - relay, D - download to fib

------------------------------------------------------------------------------

Routing Tables: Public

Destinations : 10 Routes : 10

Destination/Mask Proto Pre Cost Flags NextHop Interface

127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0

127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0

192.168.10.0/24 Static 60 0 RD 192.168.20.1 Vlanif20

192.168.20.0/24 Direct 0 0 D 192.168.20.2 Vlanif20

192.168.20.2/32 Direct 0 0 D 127.0.0.1 Vlanif20

192.168.30.0/24 Direct 0 0 D 192.168.30.254 Vlanif30

192.168.30.254/32 Direct 0 0 D 127.0.0.1 Vlanif30

192.168.40.0/24 Direct 0 0 D 192.168.40.1 Vlanif40

192.168.40.1/32 Direct 0 0 D 127.0.0.1 Vlanif40

192.168.50.0/24 Static 60 0 RD 192.168.40.2

3、在PC1上使用ping命令驗證連通性。

PC>ping 192.168.50.1

Ping 192.168.50.1: 32 data bytes, Press Ctrl_C to break

From 192.168.50.1: bytes=32 seq=1 ttl=125 time=47 ms

From 192.168.50.1: bytes=32 seq=2 ttl=125 time=78 ms

--- 192.168.50.1 ping statistics ---

2 packet(s) transmitted

2 packet(s) received

0.00% packet loss

round-trip min/avg/max = 47/62/78 ms

3、在pc1上使用Tracert命令驗證連通性。

PC>tracert 192.168.50.1

traceroute to 192.168.50.1, 8 hops max

(ICMP), press Ctrl+C to stop

1 192.168.10.254 16 ms 15 ms 32 ms

2 192.168.20.2 31 ms 47 ms 62 ms

3 192.168.40.2 78 ms 63 ms 62 ms

4 192.168.50.1 78 ms 63 ms 94 ms

 

搬運來自:https://baijiahao.baidu.com/s?id=1679777659006465785&wfr=spider&for=pc


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM