42313 发表于 2016-2-24 08:32:58

测试三层交换机ip routing和no switchport命令的区别

                                                    
PC0
       IP:               192.168.1.2
       Submark:            255.255.255.0
       Gateway:       192.168.1.1
PC1
       IP:               192.168.2.2
       Submark:            255.255.255.0
       Gateway:       192.168.2.1   
PC2
       IP:               192.168.3.2
       Submark:            255.255.255.0
       Gateway:       192.168.3.1

配置过程:
Switch>en
Switch#conf t
Enter configuration commands, one per line.End with CNTL/Z.

运行路由协议
Switch(config)#ip routing
端口1由二层转变为三层,并
配置IP地址
Switch(config)#int fa0/1
Switch(config-if)#no switchport
Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Switch(config-if)#ip address 192.168.1.1 255.255.255.0
Switch(config-if)#exit

端口3由二层转变为三层,并配置IP地址
Switch(config)#int fa0/3
Switch(config-if)#no switchport
Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up
Switch(config-if)#ip address 192.168.3.1 255.255.255.0
Switch(config-if)#no shut
Switch(config-if)#exit
Switch(config)#int fa0/1
Switch(config-if)#no shut
Switch(config-if)#exit
Switch(config)#

测试结果:


分析:
普通的可划vlan的交换机中各vlan之间是不可以通信的,而且只能有一个管理ip,而在三层交换机中每个vlan都可以设置独立的网关,ip routing这条命令的作用就是运行路由协议,让每个vlan间实现通信。no switchport命令即打开端口的三层功能。如上例,fa0/1和fa0/3使用no switchport命令开启了三层功能,由二层端口转变为三层端口,fa0/2没有开启,还是只具有二层端口功能。所以PC0和PC3可以ping通,而PC0和PC2不可以ping通。
页: [1]
查看完整版本: 测试三层交换机ip routing和no switchport命令的区别