
普通交换机工作在链路层,即二层交换机,无路由功能,也就是只能同一个网段的机器才能通信。下面是我收集的思科三层交换机路由功能配置实例,希望对你有帮助!
配置23口:
Switch#enable
Switch#configure terminal
Switch(config)#interface fastEthernet 0/23
Switch(config)ip addr 50.1.1.1 255.255.255.0
Switch(config-if)#no switchport
Switch(config-if)#no shutdown
Switch(config-if)#end
类似的配置24口:
Switch#enable
Switch#configure terminal
Switch(config)#interface fastEthernet 0/24
Switch(config)ip addr 60.1.1.1 255.255.255.0
Switch(config-if)#no switchport
Switch(config-if)#no shutdown
Switch(config-if)#end
打开交换机路由转发开关:
Switch#configure terminal
Switch(config)#ip routing
Switch(config)#ip cef (这个默认是打开的)
此时可以查看下23口的状态:
Switch#show interfaces fastEthernet 0/23
此时在交换机上ping两个口的地址成功:
Switch#ping 50.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 50.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
Switch#ping 60.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 60.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms
Switch#
pc1(win7)增加路由:
到60.1.1.0/24的`数据包通过50.1.1.1转发:
route ADD 60.1.1.0 MASK 255.255.255.0 50.1.1.1 METRIC 3
对应的pc2也增加路由:
route ADD 50.1.1.0 MASK 255.255.255.0 60.1.1.1 METRIC 3
此时50.1.1.2和60.1.1.2即可通信。
如果使用了交换机口的路由功能,那么此口(即这里的23,24口)就没有交换能力了。
如果又要交换机有路由功能,又有交换功能,那么交换功能可以由其它口负担。
三层交换机实现了VLAN间互通后,还要与其他网络进行通信,这样就需要有相关的路由机制。
交换接口配置为三层接口实现路由间通信
三层交换机既然具有三层功能,也就可以实现与路由器相似的配置。既可以把交换接口配置为三层接口,也可以在其上配置静态、动态路由。通过对三层交换机的路由配置,实现VLAN与其他网络的互通。
Switch>enable
Switch#configure terminal
Switch(config)#vlan 2
Switch(config-vlan)#vlan 3
Switch(config-vlan)#vlan 4
Switch(config-vlan)#vlan 5
Switch(config)#interface vlan 1
Switch(config-if)#ip address 192.168.1.254 255.255.255.0
Switch(config-if)#no shutdown
Switch(config)#interface vlan 2
Switch(config-if)#ip address 192.168.2.254 255.255.255.0
Switch(config-if)#no shutdown
Switch(config)#interface vlan 3
Switch(config-if)#ip address 192.168.3.254 255.255.255.0
Switch(config-if)#no shutdown
Switch(config)#interface vlan 4
Switch(config-if)#ip address 192.168.4.254 255.255.255.0
Switch(config-if)#no shutdown
Switch(config)#interface vlan 5
Switch(config-if)#ip address 192.168.5.254 255.255.255.0
Switch(config-if)#no shutdown
Switch(config)#ip routing //开启路由功能
Switch(config)#interface range f0/23-24
Switch (config-if-range)#switchport trunk encapsulation dot1q
Switch (config-if-range)#switchport mode trunk
Sw1(config)#vlan 2
Sw1(config)#vlan 2
Sw1(config-vlan)#vlan 3
Sw1(config)#interface fastEthernet 0/2
Sw1(config-if)#switchport access vlan 2
Sw1(config)#interface fastEthernet 0/3
Sw1(config-if)#switchport access vlan 3
Sw1(config)#interface fastEthernet 0/5
Sw1(config-if)#switchport mode trunk //连接三层交换机的接口配置为trunk模式
Sw2(config)#vlan 4
Sw2(config-vlan)#vlan 5
Sw2(config)#interface fastEthernet 0/1
Sw2(config-if)#switchport access vlan 4
Sw2(config)#interface f0/2
Sw2(config-if)#switchport access vlan 5
三层交换机的物理端口默认是二层端口,只具有二层特性,不能配置IP地址。把二层端口配置为三层端口后,该端口就具备路由功能了,可以配置IP地址,但同时也就关闭了其二层特性,比如不能把三层端口加入VLAN。
二层端口(交换机上的端口默认都是二层端口)默认是激活状态,那些没有使用到的端口为了安全应该手工将其禁用(shutdown);而三层端口(路由器上的端口或是三层交换机上被配置成路由端口的端口)默认是禁用状态,在使用之前务必要将其激活(no shutdown)。
Switch(config)#interface f0/6
Switch(config-if)#no switchport
Switch(config-if)#ip address 192.168.6.1 255.255.255.0
Switch(config-if)#no shutdown
Switch(config)#interface f0/0
Switch(config-if)#ip address 192.168.6.2 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#interface f0/1
Switch(config-if)#ip address 192.168.7.254 255.255.255.0
Switch(config-if)#no shutdown
Switch(config)#iproute 192.168.7.0 255.255.255.0 192.168.6.2 //格式 ip route 下一跳
Switch(config)#exit
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, Vlan1
C 192.168.2.0/24 is directly connected, Vlan2
C 192.168.3.0/24 is directly connected, Vlan3
C 192.168.4.0/24 is directly connected, Vlan4
C 192.168.5.0/24 is directly connected, Vlan5
C 192.168.6.0/24 is directly connected, FastEthernet0/6
S 192.168.7.0/24 [1/0] via 192.168.6.2
tarena-rouer(config)#ip route 192.168.1.0 255.255.255.0 192.168.6.1
tarena-rouer(config)#ip route 192.168.2.0 255.255.255.0 192.168.6.1
tarena-rouer(config)#ip route 192.168.3.0 255.255.255.0 192.168.6.1
tarena-rouer(config)#ip route 192.168.4.0 255.255.255.0 192.168.6.1
tarena-rouer(config)#ip route 192.168.5.0 255.255.255.0 192.168.6.1
tarena-rouer(config)#exit
tarena-rouer#show ip rout
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
S 192.168.1.0/24 [1/0] via 192.168.6.1
S 192.168.2.0/24 [1/0] via 192.168.6.1
S 192.168.3.0/24 [1/0] via 192.168.6.1
S 192.168.4.0/24 [1/0] via 192.168.6.1
S 192.168.5.0/24 [1/0] via 192.168.6.1
C 192.168.6.0/24 is directly connected, FastEthernet0/0
C 192.168.7.0/24 is directly connected, FastEthernet0/1
PC>ipconfig
FastEthernet0 Connection:(default port)
Link-local IPv6 Address.........: FE80::2E0:8FFF:FE14:BB43
IP Address......................: 192.168.7.1
Subnet Mask.....................: 255.255.255.0
Default Gateway.................: 192.168.7.254
SERVER>ping 192.168.1.1
Pinging 192.168.1.1 with 32 bytes of data:
Request timed out.
Reply from 192.168.1.1: bytes=32 time=0ms TTL=126
Reply from 192.168.1.1: bytes=32 time=0ms TTL=126
Reply from 192.168.1.1: bytes=32 time=1ms TTL=126
Ping statistics for 192.168.1.1:
Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms
SERVER>ping 192.168.2.1
Pinging 192.168.2.1 with 32 bytes of data:
Reply from 192.168.2.1: bytes=32 time=0ms TTL=126
Reply from 192.168.2.1: bytes=32 time=0ms TTL=126
Reply from 192.168.2.1: bytes=32 time=0ms TTL=126
Reply from 192.168.2.1: bytes=32 time=0ms TTL=126
Ping statistics for 192.168.2.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
SERVER>ping 192.168.3.1
Pinging 192.168.3.1 with 32 bytes of data:
Reply from 192.168.3.1: bytes=32 time=1ms TTL=126
Reply from 192.168.3.1: bytes=32 time=0ms TTL=126
Reply from 192.168.3.1: bytes=32 time=0ms TTL=126
Reply from 192.168.3.1: bytes=32 time=0ms TTL=126
Ping statistics for 192.168.3.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms
1、打开思科交换CLI,首先进入的是用户模式,如果要进行配置 *** 作需要进入特权模式。
2、从特权模式进入全局配置模式Switch#configure terminal Switch(config)#。
3、在特权模式下可以对交换机进行命名,这样在配置多台交换机时,避免将配置写错交换机。
4、配置交换端口密码,登录特权模式时需要输入该密码,避免设备被其他人使用。
5、给交换机配置使能密码,进入特权模式时需要输入密码才能进入,避免设备可以被其他人员使用。
6、SSH远程登录设置。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)