(一)對於路由器:
1:命名
2:禁止DNS服務
3:設置子接口協議和IP
4:開通相應接口
(二)對於交換機:
1:命名
2:添加vlan
3:將指定端口添加到相應vlan
4:將相應端口設置成trunk模式
(三)對於PC:(這裏把路由器當做PC)
1:命名
2:禁用路由功能
3:設置IP
(四)查看命令:
查看基本配置:
show running-config
查看端口命令:
show interface 端口號
查看vlan信息:
show vlan-switch
配置文檔:
R:
enable
config terminal
no ip domain-lookup //禁用DNS服務
hostname R
interface f0/0 //激活端口
no shutdown
exit
interface f0/0.1
encapsulation dot1q 2 //將相應端口添加協議並設置IP
ip address 192.168.1.35 255.255.255.224
no shutdown
exit
interface f0/0.2
encapsulation dot1q 3
ip address 192.168.1.67 255.255.255.224 //將相應端口添加協議並設置IP
no shutdown
end
write
sw1:
enable
config terminal
hostname sw1 //命名
exit
vlan database //添加vlan
vlan 2
vlan 3
exit
config terminal
interface f0/8
switchport access vlan 2 //將相應端口添加到相應vlan
interface f0/10
switchport access vlan 3 //將相應端口添加到相應vlan
exit
interface f0/1
switchport mode trunk //將相應端口設置成中繼
interface f0/2
switchport mode trunk //將相應端口設置成中繼
end
write
sw2:
enable
config terminal
hostname sw2 //命名
exit
vlan database //添加vlan
vlan 2
vlan 3
exit
config terminal
interface f0/8
switchport access vlan 2 //將相應端口添加到相應vlan
interface f0/10
switchport access vlan 3 //將相應端口添加到相應vlan
exit
interface f0/1
switchport mode trunk //將相應端口設置成trunk模式
end
write
PC1:
enable
config terminal
no ip routing
hostname PC1
interface f0/0
ip address 192.168.1.33 255.255.255.224 //設置IP
no shutdown
end
write
PC2:
enable
config terminal
no ip routing
hostname PC2
interface f0/0
ip address 192.168.1.65 255.255.255.224 //設置IP
no shutdown
end
write
PC3:
enable
config terminal
no ip routing
hostname PC3
interface f0/0
ip address 192.168.1.34 255.255.255.224 //設置IP
no shutdown
end
write
PC4:
enable
config terminal
no ip routing
hostname PC4
interface f0/0
ip address 192.168.1.66 255.255.255.224 //設置IP
no shutdown
end
write
測試截圖:
路由器上查看鄰居:
交換機上查看鄰居:
交換機2上查看vlan:
交換機1上查看vlan:
交換機上查看trunk端口:
交換機上查看trunk端口:
交換機上查看trunk端口:
在PC1上Ping其它PC.: