在一台三层交换上,不同VLAN相互通信配置方法
本实验需求:
通过在cisco catalyst 3550来规划VLAN 100 和VLAN 200,并且配置DHCP 让VLAN100人事部计算机获得IP地址为192.168.0.0/24,让VLAN200市场部计算机获得IP地址为172.16.0.0/24。因为市场部和人事部因为业务上的关系,需要两台服务器相互通信,所在还需要在3550上配置VLAN间相互通信。
实验拓扑:
实验过程 第一步 配置Catalyst 3550基础配置
复制代码
代码如下:
Switch>
Switch>enable
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#host 3550
3550(config)#no ip do lo
3550(config)#line con 0
3550(config-line)#no exec-t
3550(config-line)#logg syn
3550(config-line)#exit
第二步 在Catalyst 3550 划分VLAN 100和VLAN 200 //进入全局配置模式下,划分VLAN(请问catalyst 3500支持在全局模式下划分VLAN吗?)
复制代码
代码如下:
3550(config)#vlan 100
//给VLAN100命名
3550(config-vlan)#name renshibo
3550(config-vlan)#int f0/13
3550(config-if)#switchport mode access
3550(config-if)#switchport access vlan 100
3550(config-if)#spanning-tree portfast
//请问什么时候需要在交换机接口下配置portfast?这里如果不配置可以吗?
%Warning: portfast should only be enabled on ports connected to a single
host. Connecting hubs, concentrators, switches, bridges, etc... to this
interface when portfast is enabled, can cause temporary bridging loops.
Use with CAUTION
%Portfast has been configured on FastEthernet0/13 but will only
have effect when the interface is in a non-trunking mode.
3550(config-if)#vlan 200
3550(config-vlan)#name shichangbo
3550(config-vlan)#int f0/15
3550(config-if)#sw mo acc
3550(config-if)#sw acc vlan 200
3550(config-if)#spanning-tree portfast
%Warning: portfast should only be enabled on ports connected to a single
host. Connecting hubs, concentrators, switches, bridges, etc... to this
interface when portfast is enabled, can cause temporary bridging loops.
Use with CAUTION
%Portfast has been configured on FastEthernet0/15 but will only
have effect when the interface is in a non-trunking mode.
//验证VLAN的配置
3550#show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
Fa0/14, Fa0/16, Fa0/17, Fa0/18
Fa0/23, Gi0/1, Gi0/2
100 renshibo active Fa0/13
200 shichangbo active Fa0/15
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup
第三步 配置SVI(交换虚拟接口)
复制代码
代码如下:
3550#conf t
Enter configuration commands, one per line. End with CNTL/Z.
//进入VLAN 100 虚拟接口下
3550(config)#int vlan 100
//增加接口描述,以便将来排错更加方便
3550(config-if)#description Connection to renshibo
//这里配置的IP地址就是人事部PC的默认网关地址,如果VLAN接口不配置IP地址,后面的DHCP配置中,PC能否获得IP地址吗??
3550(config-if)#ip add 192.168.0.1 255.255.255.0
3550(config-if)#no sh
3550(config-if)#int vlan 200
00:13:22: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan200, changed state to up
3550(config-if)#description Connection to shichangbo
3550(config-if)#ip add 172.16.0.1 255.255.255.0
3550(config-if)#no sh
3550(config-if)#
3550#conf t
//开启catalyst 3550三层交换路由功能(默认是关闭的)
请问cisco catalyst那些型号交换机是三层交换机?
3550(config)#ip routing
3550(config)#exit
3550#sh ip route
//两条直连路由条目
Codes: C - connected, S - static, 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, su - IS-IS summary, 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
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.0.0 is directly connected, Vlan200
C 192.168.0.0/24 is directly connected, Vlan100
Designated bridge has priority 32768, address ccd1.0a80.0000
Designated port id is 129.65, designated path cost 0
Timers: message age 0, forward delay 0, hold 0
Number of transitions to forwarding state: 1
BPDU: sent 993, received 92
第四步 在Catalyst 3550上配置DHCP,以便于VLAN100和VLAN200下客户端获得IP地址,掩码,网关,DNS等
复制代码
代码如下:
//全局下打开DHCP服务.默认是开启的吗?那为什么还要需要开启了?
3550(config)#service dhcp
//关闭dhcp 客户端IP冲突日志记录信息
3550(config)#no ip dhcp conflict logging
//配置地址池名称,地址池名称为任意字符(这里定义的名字VLAN的名称)
3550(config)#ip dhcp pool renshibo
//配置PC所获得网段地址范围,和掩码,(这里有几种命令语句格式)
(network 192.168.0.0 255.255.255.0)
3550(dhcp-config)#network 192.168.0.0 /24
//配置网关地址
3550(dhcp-config)#default-router 192.168.0.1
//配置DNS(域名解析服务器)可选配置
请问什么时候PC需要配置DNS地址?局域网通讯需要吗?
3550(dhcp-config)#dns 218.30.19.40 61.134.1.4
//配置域名
3550(dhcp-config)#domain-name www.cisco.com
//配置地址租期为永久
3550(dhcp-config)#lease infinite
3550(dhcp-config)#exit
//配置排除的IP地址范围,不从地址池内分配的地址,不配置排除地址可以吗?
3550(config)#ip dhcp excluded-address 192.168.0.1
3550(config)#ip dhcp pool shichangbo
3550(dhcp-config)#network 172.16.0.0 /24
3550(dhcp-config)#default-router 172.16.0.1
3550(dhcp-config)#dns 218.30.19.40 61.134.1.4
3550(dhcp-config)#domain-name www.cisco.com
3550(dhcp-config)#lease infinite
3550(dhcp-config)#exit
3550(config)#ip dhcp excluded-address 172.16.0.1
第五步 在市场部PC上验证是否能从catalyst 3550获得IP地址, 如图:开始-运行-cmd-ipconfig /all
第六步 在Catalyst 3550查看PC获得的IP地址是否正确
复制代码
代码如下:
//查看DHCP绑定信息
3550#sh ip dhcp binding
IP address Client-ID/ (MAC地址) Lease expiration Type
Hardware address
172.16.0.2 0100.16d3.249f.fd Infinite Automatic
192.168.0.2 0100.1641.15e8.5c Infinite Automatic
第七步 在交换机测试是否可以ping通市场部和人事部PC
复制代码
代码如下:
3550(config)#exit
3550#
00:26:41: %SYS-5-CONFIG_I: Configured from console by console
3550#ping 172.16.0.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
3550#ping 192.168.0.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms
第八步 在市场部PC上用ping命令测试是否可以ping通VLAN100(人事部) 下PC 如图:测试结果如下,可以ping通,实验现象成功!
本文出自 “王万利的博客” 博客