
配置命令:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
——SW2L——
SW<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />2L#vlan database
SW2L(vlan)#vlan 20 name v20
SW2L(vlan)#vlan 30 name v30
SW2L(vlan)#vlan 40 name v40
SW2L(vlan)#exit
---------------------------------------------------------------------------------------------------
SW2L#config terminal
SW2L(config)#interface f0/1
SW2L(config-if)#switchport mode trunk
SW2L(config)#interface f0/2
SW2L(config-if)#switchport mode access
SW2L(config-if)#switchport access vlan 20
SW2L(config)#interface f0/3
SW2L(config-if)#switchport mode access
SW2L(config-if)#switchport access vlan 30
SW2L(config)#interface f0/4
SW2L(config-if)#switchport mode access
SW2L(config-if)#switchport access vlan 40
SW2L(config-if)#exit
---------------------------------------------------------------------------------------------------
SW2L#show vlan
SW2L#show running-config
——SW3L——
SW3L#vlan database
SW3L(vlan)#vlan 20 name v20
SW3L(vlan)#vlan 30 name v30
SW3L(vlan)#vlan 40 name v40
SW3L(vlan)#exit
---------------------------------------------------------------------------------------------------
SW3L#config terminal
SW3L(config)#interface vlan 20
SW3L(config-if)#ip address 192.168.20.1 255.255.255.0
SW3L(config-if)#no shutdown
SW3L(config-if)#exit
SW3L(config)#interface vlan 30
SW3L(config-if)#ip address 192.168.30.1 255.255.255.0
SW3L(config-if)#no shutdown
SW3L(config-if)#exit
SW3L(config)#interface vlan 40
SW3L(config-if)#ip address 192.168.40.1 255.255.255.0
SW3L(config-if)#no shutdown
SW3L(config-if)#exit
---------------------------------------------------------------------------------------------------
SW3L#config terminal
SW3L(config)#interface f1/0/2
SW3L(config-if)#no switchport
SW3L(config-if)#ip address 192.168.1.1 255.255.255.0
SW3L(config-if)#no shutdown
SW3L(config-if)#exit
---------------------------------------------------------------------------------------------------
SW3L#config terminal
SW3L(config)#router rip
SW3L(config-router)#network 192.168.20.0
SW3L(config-router)#network 192.168.30.0
SW3L(config-router)#network 192.168.40.0
SW3L(config-router)#network 192.168.1.0
SW3L(config-router)#exit
——Router——
Router#config terminal
Router(config)#interface f0/1
Router(config-if)#ip address 192.168.1.2 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#interface f0/0
Router(config-if)#ip address 192.168.4.1 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#exit
---------------------------------------------------------------------------------------------------
Router#config terminal
Router(config)#router rip
Router(config-router)#network 192.168.1.0
Router(config-router)#network 192.168.4.0
SW3L(config-router)#exit
——各个PC设置——
主机 |
IP |
Netmask |
Gateway |
A |
192.168.20.2 |
255.255.255.0 |
192.168.20.1 |
B |
192.168.30.2 |
255.255.255.0 |
192.168.30.1 |
C |
192.168.40.2 |
255.255.255.0 |
192.168.40.1 |
D |
192.168.4.2 |
255.255.255.0 |
192.168.40.1 |
——实验检验——
SW2L#show vlan
SW2L#show running-config
SW2L#show interface f0/1 switchport
---------------------------------------------------------------------------------------------------
SW3L#show vlan
SW3L#show running-config
SW3L#show ip route
//可以看见4条直连和1条RIP路由信息
SW3L#show cef
SW3L#show adjacency detail
---------------------------------------------------------------------------------------------------
Router#show running-config
Router#show ip route
//可以看见2条直连和3条RIP路由信息
转载于:https://blog.51cto.com/sonofgod/124484