1. 程式人生 > >單臂路由 不同vlan不同網段之間互通

單臂路由 不同vlan不同網段之間互通

R1、R2為交換機,R3~R5為pc,R6為路由器
R3(config)#no ip routing
R3(config)#int f0/0
R3(config-if)#ip add 192.168.10.1 255.255.255.0
R3(config-if)#no shut
R3(config-if)#end
R3(config)#ip default-gateway 192.168.10.254
R3#show ip route
Default gateway is 192.168.10.254
Host               Gateway           Last Use    Total Uses  Interface
ICMP redirect cache is empty

R4(config)#no ip routing
R4(config)#int f0/0
R4(config-if)#ip add 192.168.20.1 255.255.255.0
R4(config-if)#no shut 
R4(config-if)#end
R4(config)#ip default-gateway 192.168.20.254
R4#show ip route
Default gateway is 192.168.20.254
Host               Gateway           Last Use    Total Uses  Interface
ICMP redirect cache is empty

R5(config)#no ip routing
R5(config)#int f0/0
R5(config-if)#ip add 192.168.10.2 255.255.255.0
R5(config-if)#no shut
R5(config-if)#end
R5(config)#ip default-gateway 192.168.10.254
R5#show ip route
Default gateway is 192.168.10.254
Host               Gateway           Last Use    Total Uses  Interface
ICMP redirect cache is empty

R1#vlan database
R1(vlan)#vlan 10
VLAN 10 added:
    Name: VLAN0010
R1(vlan)#vlan 20
VLAN 20 added:
    Name: VLAN0020
R1(vlan)#exit
R1#conf t
R1(config)#int f0/0
R1(config-if)#switchport mode access
R1(config-if)#switchport access vlan 10
R1(config-if)#int f0/1
R1(config-if)#switchport mode access
R1(config-if)#switchport access vlan 20
R1(config-if)#end
R1(config)#int f0/15
R1(config-if)#switchport trunk encapsulation dot1q
R1(config-if)#switchport mode trunk
R1(config-if)#end

R2#vlan database
R2(vlan)#vlan 10
VLAN 10 added:
    Name: VLAN0010
R2(vlan)#vlan 20
VLAN 20 added:
    Name: VLAN0020
R2(vlan)#exit
R2#conf t
R2(config)#int f0/0
R2(config-if)#switchport mode access
R2(config-if)#switchport access vlan 10
R2(config-if)#int f0/1
R2(config-if)#switchport trunk encapsulation dot1q
R2(config-if)#switchport mode trunk
R2(config-if)#end
R2(config)#int f0/15
R2(config-if)#switchport trunk encapsulation dot1q
R2(config-if)#switchport mode trunk
R2(config-if)#end


R6(config)#int f0/0
R6(config-if)#no shut  先開啟物理介面
R6(config-if)#end
R6(config)#int f0/0.10
R6(config-subif)#encapsulation dot1Q 10
R6(config-subif)#ip add 192.168.10.254 255.255.255.0
R6(config-subif)#no shut
R6(config-subif)#exit
R6(config)#int f0/0.20
R6(config-subif)#encapsulation dot1Q 20
R6(config-subif)#ip address 192.168.20.254 255.255.255.0
R6(config-subif)#no shut
到此實現了不同vlan和不同網段之間的互通!
default interface f0/0 此命令將介面設為預設值