实验拓朴:
实验目标:
目标1.配置三层交换,是内部VLAN间互通
目标2.配置DHCP中继,使VLAN2中的DHCP SERVER对VLAN3中的CLIENT生效
实验拓朴改动说明:
Switch1 F0/0 <----> Router1 E0/0
Switch1 F0/15 <----> Switch2 F0/15
Switch2 F0/2 <----> XPC P0/1 (net1 vlan2 ,VS4 ,做DHCP SERVER)
Switch2 F0/3 <----> XPC P0/0 (net8 vlan3 ,VS3 CLIENT)
在二层交换机上我只桥接了2台虚拟PC,VS4 ,VS3
VS4 :IP:192.168.2.1 /24
GW:192.168.2.54 VLAN 2
VS3:IP:192.168.3.1 / 24
GW:192.168.3.254 VLAN3
VLAN 1 不用。
实验步骤:
目标1:配置三层交换是内部VLAN之间可以互通.
1. sw1-3(config)#in ( trunk start)
sw1-3(config)#interface f0/15
sw1-3(config-if)#sw
sw1-3(config-if)#switchport mo
sw1-3(config-if)#switchport mode tr
sw1-3(config-if)#no sh
sw1-3(config)#interface f0/0
sw1-3(config-if)#sw
sw1-3(config-if)#switchport mo
sw1-3(config-if)#switchport mode tr
sw1-3(config-if)#switchport mode trunk
sw1-3(config-if)#no sh
2. sw1-3#vl da (config vtp server)
sw1-3(vlan)#vtp domain test
Changing VTP domain name from NULL to test
sw1-3(vlan)#vtp server
Device mode already VTP SERVER.
sw1-3(vlan)#vtp password 111111
Setting device VLAN database password to 111111.
sw1-3(vlan)#vtp v2-mode
V2 mode enabled.
sw1-3(vlan)#vtp pruning
Pruning switched ON
sw1-3(vlan)#exit
3. sw2-2
start trunk (和SW1-3 相同配置,略)
config vtp client (和SW1-3配置差不多,略)
4. sw1-3#vl da
sw1-3(vlan)#vlan 2 name v2
VLAN 2 added:
Name: v2
sw1-3(vlan)#apply
APPLY completed.
sw1-3(vlan)#vlan 3 name v3
VLAN 3 added:
Name: v3
sw1-3(vlan)#apply
APPLY completed.
sw1-3(vlan)#exit
APPLY completed.
Exiting....
sw1-3#exit
5. CLIENT TEST
sw2-2#show vlan-switch
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/0, 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/13, Fa0/14
2 v2 active
3 v3 active
1002 fddi-default active
1003 trcrf-default active
1004 fddinet-default active
1005 trbrf-default active
6. sw2-2#conf t (划分接口到VLAN中)
Enter configuration commands, one per line. End with CNTL/Z.
sw2-2(config)#interface f0/2
sw2-2(config-if)#switchport access vlan 2
sw2-2(config-if)#switchport mode access (定义为二层接口)
sw2-2(config-if)#no sh
sw2-2(config-if)#exit
sw2-2(config)#interface f0/3
sw2-2(config-if)#switchport access vlan 3
sw2-2(config-if)#switchport mode access
sw2-2(config-if)#no sh
sw2-2(config-if)#exit
sw2-2(config)#exit
sw2-2#
7.sw2-2#show vlan-switch ( test)
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/0, Fa0/1, Fa0/4, Fa0/5
Fa0/6, Fa0/7, Fa0/8, Fa0/9
Fa0/10, Fa0/11, Fa0/12, Fa0/13
Fa0/14
2 v2 active Fa0/2
3 v3 active Fa0/3
1002 fddi-default active
1003 trcrf-default active
1004 fddinet-default active
1005 trbrf-default active
8. sw1-3(config)#ip routing (start 路由功能)
9. sw1-3(config)#interface vlan 2 (三层交换机上VLAN 配IP。为二层VLAN GW)
sw1-3(config-if)#ip add 192.168.2.254 255.255.255.0
sw1-3(config-if)#no sh
sw1-3(config-if)#exit
sw1-3(config)#interface vlan 3
sw1-3(config-if)#ip add 192.168.3.254 255.255.255.0
sw1-3(config-if)#no sh
sw1-3(config-if)#exit
sw1-3#show 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
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
C 192.168.2.0/24 is directly connected, Vlan2
C 192.168.3.0/24 is directly connected, Vlan3
10.sw1-3#show ip in br ( TEST)
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES unset up up
FastEthernet0/1 unassigned YES unset up down
FastEthernet0/2 unassigned YES unset up down
FastEthernet0/3 unassigned YES unset up down
FastEthernet0/4 unassigned YES unset up down
FastEthernet0/5 unassigned YES unset up down
FastEthernet0/6 unassigned YES unset up down
FastEthernet0/7 unassigned YES unset up down
FastEthernet0/8 unassigned YES unset up down
FastEthernet0/9 unassigned YES unset up down
FastEthernet0/10 unassigned YES unset up down
FastEthernet0/11 unassigned YES unset up down
FastEthernet0/12 unassigned YES unset up down
FastEthernet0/13 unassigned YES unset up down
FastEthernet0/14 unassigned YES unset up down
FastEthernet0/15 unassigned YES unset up up
Vlan1 unassigned YES unset up up
Vlan2 192.168.2.254 YES manual up up
Vlan3 192.168.3.254 YES manual up up
11.测试不同的VLAN间是否能正常通信.
1> V2 -----VS4.
2> V3-----VS3
12. 在三层交换机上配置路由接口和IP ,并运行RIP 。在路由器上配置相应接口的IP ,并运行RIP,结果,使VALN 2 和VLAN 3 中的主机可以通过三层交换和外部相通。
sw1-3(config-if)#interface f0/0
sw1-3(config-if)#no switchport ( 关掉接口交换功能)
sw1-3(config-if)#ip add 192.168.5.1 255.255.255.0
sw1-3(config-if)#no sh
sw1-3(config-if)#exit
sw1-3(config)#exit
sw1-3#show ip in br
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.5.1 YES manual up up
FastEthernet0/1 unassigned YES unset up down
sw1-3(config)#router rip (运行RIP)
sw1-3(config-router)#network 192.168.5.0
sw1-3(config-router)#network 192.168.2.0
sw1-3(config-router)#network 192.168.3.0
sw1-3(config-router)#exit
sw1-3(config)#exit
sw1-3#show 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
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
C 192.168.5.0/24 is directly connected, FastEthernet0/0
R 192.168.6.0/24 [120/1] via 192.168.5.2, 00:00:03, FastEthernet0/0
C 192.168.2.0/24 is directly connected, Vlan2
C 192.168.3.0/24 is directly connected, Vlan3
sw1-3#
R1(config)#interface e0/0
R1(config-if)#ip add 192.168.5.2 255.255.255.0
R1(config-if)#no sh
R1(config-if)#exi
R1(config)#interface lo0
(环回)
R1(config-if)#ip add 192.168.6.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#exit
R1(config)#exit
R1#show ip in br
Interface IP-Address OK? Method Status Protocol
Ethernet0/0 192.168.5.2 YES manual up up
Ethernet0/1 unassigned YES unset administratively down down
Ethernet0/2 unassigned YES unset administratively down down
Ethernet0/3 unassigned YES unset administratively down down
Loopback0 192.168.6.1 YES manual up up
R1(config)#router rip
(运行RIP)
R1(config-router)#network 192.168.5.0
R1(config-router)#network 192.168.6.0
R1(config-router)#exit
R1(config)#exit
R1#show 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
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
C 192.168.5.0/24 is directly connected, Ethernet0/0
C 192.168.6.0/24 is directly connected, Loopback0
R 192.168.2.0/24 [120/1] via 192.168.5.1, 00:00:03, Ethernet0/0
R 192.168.3.0/24 [120/1] via 192.168.5.1, 00:00:03, Ethernet0/0
13.测试前面的配置结果.
14.测试成功后,下一步,反之,检查是那个地方配错.
目标2:配置DHCP中继,使VLAN2中的DHCP SERVER对VLAN3中的CLIENT生效.
1.在VLAN2中的主机中配置DHCP SERVER.使它能为VLAN3中的CLINET动态分配IP地址.
2.在本地的客户端测试能否行到IP地址.
成功.
3.要VLAN3上的客户机上进行测试,看是否能得到IP地址.
失败了.
原因很明: 之所以VLAN 3中的CLIENT 没有得到IP ,是因为不同VLAN 之间相通是要通过路由的,而在,申请IP时,用的是广播地址,路由是隔离广播的,所以,没有得以IP ,
4.解决的方法:就是在,三层交换机
上面做中继代理.
sw1-3(config)#interface vlan 2
sw1-3(config-if)#ip helper-address 192.168.2.1
sw1-3(config-if)#exit
sw1-3(config)#interface vlan 3
sw1-3(config-if)#ip helper-address 192.168.2.1
sw1-3(config-if)#exit
sw1-3(confi)
5.配置完中继代理测试.
配置成功.
本文出自 “michaelfung_专栏” 博客,转载请与作者联系!