1. 程式人生 > 實用技巧 >三層交換與DHCP中繼2

三層交換與DHCP中繼2

實驗拓樸: 拓樸說明: 此拓樸是用一臺路由器做DHCP SERVER ,給所有客戶端分配IP地址. 實驗目的: 能夠讓VLAN 2 中的PC 機通過三層交換機上的DHCP 中繼功能從VLAN 3 中的路由器上的DHCP SERVER 中得到IP 地址 實驗步驟: 1.搭環境. Switch1 F0/15 <----> Switch2 F0/15
Switch2 F0/3 < ----> Router1 E0/1 (vlan 3)
Switch2 F0/2 <----> XPC P0/0 (vlan 2,net1)
2. 在SW1-3 和 SW2-2 中開啟F0/15為中繼埠(TRUNK.略)
3. 在SW1-3 和 SW2-2 上做VTP,並且,新建VLAN 2,3(略) SW1-3為VTP SERVER,並新建VLAN 2 ,3。2
SW2-2為VTP CLIENT。

4. 在SW1-3和SW2-2中分別測試VLAN是否OK! (略)

5. SW2-2中劃介面F0/2到VLAN 2,劃介面F0/3到VLAN 3。
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#
6.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
6.sw1-3(config)#ip routing開啟三層交換機的路由功能.

7.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(config)#interface vlan 2
sw1-3(config-if)#ip add 192.168.2.254 255.255.255.0
sw1-3(config-if)#no sh
8.sw1-3#show ip in br
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES unset up down
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

9. 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.R1(config)#interface e0/1
R1(config-if)#ip add 192.168.3.1 255.255.255.0
R1(config-if)#no sh

11.sw1-3#conf t
Enter configuration commands, one per line. End with CNTL/Z.
sw1-3(config)#router rip
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)#exi

12.Router #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.3.0/24 is directly connected, Ethernet0/0 r1#ping 192.168.2.1 Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
13. R1(config)#router rip (R1執行RIP)
R1(config-router)#network 192.168.3.0
R1(config-router)#exit
R1(config)#exit
14.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 R 192.168.2.0/24 [120/1] via 192.168.3.254, 00:00:14, Ethernet0/0
C 192.168.3.0/24 is directly connected, Ethernet0/0
r1#ping 192.168.2.1 Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/62/104 ms
15.R1 上面做DHCP SERVER。
Router#conf t
Router(config)#ip dhcp pool 192.168.2.0
Router(dhcp-config)#network 192.168.2.0 255.255.255.0
Router(dhcp-config)#default-router 192.168.2.254
Router(dhcp-config)#dns-server 202.96.128.166 192.168.2.254
16.測試沒有配置中繼之前,客戶機能否得到IP 地址. 失敗. 17.在三層交換機上配置中繼代理. sw1-3#conf t<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Enter configuration commands, one per line. End with CNTL/Z.

sw1-3(config)#interface vlan 2

sw1-3(config-if)#ip helper-address 192.168.3.1 {中繼}

sw1-3(config)#exit

sw1-3# 18.測試中繼的配置是否正確. VLAN2中的PC機,向VLAN3中的,以路由器做的DHCP SERVER申請IP地址. 配置完成.如有問題,請你多指教. 謝謝 michaelfung.



轉載於:https://blog.51cto.com/michaelfung/211458