(一)对于路由器:
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.: