您的位置:首页 > 其它

Packer tracer实验命令总结

2016-11-25 09:31 295 查看
实验课考试,包括三层交换机和两层交换机,设计网络,命令比较碎,所以记录下来以防万一。

设置交换机的管理ip(二层三层均可)

Switch>enable
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#interface vlan 1
Switch(config-if)#ip address 192.168.2.10 255.255.255.0
Switch(config-if)#exit
Switch(config)#exit
Switch#


二层交换机设置24口为trunk口(二层交换机和其他交换机相连,一定一定要配置trunk口,该命令不能给三层交换机设置trunk,三层好像默认有trunk口,不需要我们设置)

Switch#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#interface fa0/24
Switch(config-if)#switchport mode trunk
Switch(config-if)#end
Switch#


三层交换机给vlan设置网关(配置网关后,也一定要给相应的pc机配置对应网关,否则不能ping通)

Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#ip routing
Switch(config)#interface vlan 200
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan200, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan200, changed state to up

Switch(config-if)#ip address 192.168.2.1 255.255.255.0
Switch(config-if)#no shut
Switch(config-if)#exit


设置网关时要注意网关的命名方式:最后一个网段一定得是1.

例如:192.168.3.1 192.168.4.1

划分交换机的vlan(二层或三层均可)

Switch>en
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#vlan 10
Switch(config-vlan)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up

Switch(config-vlan)#interface fa0/1
Switch(config-if)#switchport access vlan 10
Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up
exit
Switch(config)#vlan 20
Switch(config-vlan)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up

Switch(config-vlan)#interface fa0/2
Switch(config-if)#switchport access vlan 20
Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up

Switch(config-if)#exit
Switch(config)#exit
Switch#


查看三层交换机的网关是否设置成功

Switch#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route

Gateway of last resort is not set

C    192.168.1.0/24 is directly connected, Vlan100
C    192.168.2.0/24 is directly connected, Vlan200
C    192.168.3.0/24 is directly connected, Vlan300


这里的13.14.15行分别是给三个vlan设置的网关。这里表示已经设置成功。在设置网关之前,一定要先给三层交换机的不同端口划分vlan,再给每个vlan设置网关,这样才会显示配置成功。

查看二层交换机的vlan配置

Switch#show running
Building configuration...

Current configuration : 1078 bytes
!
version 12.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Switch
!
!
!
spanning-tree mode pvst
!
interface FastEthernet0/1
switchport access vlan 10
!
interface FastEthernet0/2
switchport access vlan 20
!
interface FastEthernet0/3
!
interface FastEthernet0/4
!
interface FastEthernet0/5
!
interface FastEthernet0/6
!
interface FastEthernet0/7
!
interface FastEthernet0/8
!
interface FastEthernet0/9
!
interface FastEthernet0/10
!
interface FastEthernet0/11
!
interface FastEthernet0/12
!
interface FastEthernet0/13
!
interface FastEthernet0/14
!
interface FastEthernet0/15
!
interface FastEthernet0/16
!
interface FastEthernet0/17
!
interface FastEthernet0/18
!
interface FastEthernet0/19
!
interface FastEthernet0/20
!
interface FastEthernet0/21
!
interface FastEthernet0/22
!
interface FastEthernet0/23
!
interface FastEthernet0/24
switchport mode trunk
!
interface Vlan1
ip address 192.168.2.20 255.255.255.0
shutdown
!
!
!
!
line con 0
!
line vty 0 4
login
line vty 5 15
login
!
!
end


实验过程中提示命令可能会与这里列出的有所不同,但大体一致。

要注意:

pc与交换机,交换机与交换机用不同类型的连接线。

如果没有设置网关,那么网络拓扑中同一个vlan名下的pc均能相互ping同。如果pc还设置了对应网关(三层交换机网关设置成功的前提下),那么这些pc都能够相互ping通。

没有在分配vlan的端口下的pc机默认在vlan1下,此时可以和交换机的管理ip进行ping通,一旦划分vlan,在该vlan端口下(非vlan1)不能再和它上面的交换机ping通
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: