2017-7-9基于思科模拟器ZKY正品体育
思科模拟器DHCP服务器中继实验【DHCP服务器中继案例1】只有⼀个⽹段的DHCP中继其中路由器作为DHCP服务器,交换机作为中继
⼀、交换机配置过程Switch>Switch>enSwitch#conf
Switch(config)#vlan 10 创建VLAN 10Switch(config-vlan)#exit
Switch(config)#int vlan 10
Switch(config-if)#ip address 192.168.10.254 255.255.255.0 为VLAN 10配置地址Switch(config-if)#no shut 开启虚拟接⼝Switch(config-if)#exitSwitch(config)#int fa0/1
Switch(config-if)#switchport access vlan 10 将fa0/1加⼊vlan 10Switch(config-if)#exitSwitch(config)#int fa0/24
Switch(config-if)#no switchport 将交换⼝转换为路由⼝Switch(config-if)#ip ad
Switch(config-if)#ip address 172.16.1.1 255.255.255.0Switch(config-if)#no shutSwitch(config-if)#ex
Switch(config)#ip route 0.0.0.0 0.0.0.0 172.16.1.2Switch(config-if)#Switch(config-if)#exitSwitch(config)#int vlan 10Switch(config-if)#ip ?
access-group Specify access control for packetsaddress Set the IP address of an interfacehello-interval Configures IP-EIGRP hello interval
helper-address Specify a destination address for UDP broadcasts nat NAT interface commandsospf OSPF interface commandsproxy-arp Enable proxy ARPsplit-horizon Perform split horizon
summary-address Perform address summarizationSwitch(config-if)#ip help
Switch(config-if)#ip helper-address 172.16.1.2Switch(config-if)#endSwitch#
%SYS-5-CONFIG_I: Configured from console by consoleSwitch#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - 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 - ODRP - periodic downloaded static route
Gateway of last resort is 172.16.1.2 to network 0.0.0.0172.16.0.0/24 is subnetted, 1 subnets
C 172.16.1.0 is directly connected, FastEthernet0/24C 192.168.10.0/24 is directly connected, Vlan10S* 0.0.0.0/0 [1/0] via 172.16.1.2Switch#conf
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#ip routingSwitch(config)#endSwitch#
%SYS-5-CONFIG_I: Configured from console by consoleSwitch#wr
Building configuration...⼆、路由器配置过程Router>enRouter#conf
Router(config)#int f0/0
Router(config-if)#ip address 172.16.1.2 255.255.255.0Router(config-if)#exitRouter(config)#ip dhcp ?
excluded-address Prevent DHCP from assigning certain addressespool Configure DHCP address pools
Router(config)#ip dhcp excluded-address 192.168.10.254 排除地址,避免客户端获得此IP地址产⽣冲突Router(config)#ip dhcp pool vlan10 (创建地址池vlan10)
Router(dhcp-config)#? (通过?可以知道DHCP服务器可以配置哪些选项)default-router Default routersdns-server Set name server
exit Exit from DHCP pool configuration modenetwork Network number and maskno Negate a command or set its defaultsoption Raw DHCP options
Router(dhcp-config)#default-router 192.168.10.254 (为客户端配置默认⽹关)
Router(dhcp-config)#dns-server 192.168.10.254 (为客户端配置DNS)Router(dhcp-config)#net
Router(dhcp-config)#network 192.168.10.0 255.255.255.0 (客户端所在⽹络及掩码)Router(dhcp-config)#endRouter(config)#ip route 0.0.0.0 0.0.0.0 172.16.1.1Router(config)#int fa0/0Router(config-if)#no shut
【DHCP服务器中继案例2】有多个⽹段的DHCP中继
⼀、交换机配置过程Switch>enSwitch#conf t
Enter configuration commands, one per line. End with CNTL/Z.1.创建vlan 10,vlan20,vlan 30Switch(config)#vlan 10Switch(config-vlan)#vlan 20Switch(config-vlan)#vlan 30Switch(config-vlan)#
2.为3个vlan创建相应的IP地址,并在vlan中创建中继,指向DHCP服务器地址Switch(config)#interface vlan 10
Switch(config-if)#ip address 192.168.10.254 255.255.255.0Switch(config-if)#ip helper-address 172.16.1.2Switch(config)#interface vlan 20
Switch(config-if)#ip address 192.168.20.254 255.255.255.0Switch(config-if)#ip helper-address 172.16.1.2Switch(config-if)#exit
Switch(config)#interface vlan 30
Switch(config-if)#ip address 10.0.0.1 255.0.0.0
Switch(config-if)#ip helper-address 172.16.1.2
3.将fa0/1,fa0/11,fa0/21分别加⼊vlan 10,vlan 20,vlan 30Switch(config)#interface fastEthernet 0/1Switch(config-if)#switchport access vlan 10Switch(config)#interface fastEthernet 0/11Switch(config-if)#switchport access vlan 20Switch(config-if)#exit
Switch(config)#interface fastEthernet 0/21Switch(config-if)#switchport access vlan 30Switch(config-if)#Switch(config-if)#
4.将fa0/24设置为路由⼝,并设置IP地址Switch(config)#interface fastEthernet 0/24Switch(config-if)#no switchport
Switch(config-if)#ip address 172.16.1.1 255.255.255.252Switch(config-if)#
5.设置默认路由,指向下⼀跳地址(即路由器接⼝地址)Switch(config-if)#exit
Switch(config)#ip route 0.0.0.0 0.0.0.0 172.16.1.2Switch(config)#
6.交换机开启路由功能(总是会忘记这个,忘记了N次了)Switch(config)#ip routing7.保存配置Switch(config)#exitSwitch#
%SYS-5-CONFIG_I: Configured from console by consoleSwitch#wr
Building configuration...[OK]Switch#
⼆、路由器配置过程
1.为路由器接⼝fa0/0配置IP地址,并开启接⼝Router>enRouter#conf t
Router(config)#interface fastEthernet 0/0
Router(config-if)#ip address 172.16.1.2 255.255.255.252
Router(config-if)#no shutdown (路由器默认情况下端⼝是禁⽤的,所以要开启,⽽交换机默认情况下端⼝是开启的,所以不需要敲此条命令)Router(config-if)#
2.添加排除地址,避免客户端获得如下地址,产⽣IP地址冲突。
Router(config)#ip dhcp excluded-address 10.0.0.1 因为交换机vlan 30的IP地址是10.0.0.1
Router(config)#ip dhcp excluded-address 192.168.10.254 因为交换机vlan 10⾥⾯有IP地址是192.168.10.254,虽然没有以192.168.10.1开头,建议还是排除掉
Router(config)#ip dhcp excluded-address 192.168.20.254 因为交换机vlan 20⾥⾯有IP地址是192.168.20.254,虽然没有以192.168.20.1开头,建议还是排除掉
Router(config)#ip dhcp excluded-address 192.168.20.1 192.168.20.10 如果这段IP地址有特殊⽤途,也可以排除掉3、创建DHCP服务,为3个不同⽹段的客户端分配IP地址Router(config)#ip dhcp pool vlan10
Router(dhcp-config)#default-router 192.168.10.254Router(dhcp-config)#dns-server 192.168.10.254
Router(dhcp-config)#network 192.168.10.0 255.255.255.0Router(dhcp-config)#exit
Router(config)#ip dhcp pool vlan20
Router(dhcp-config)#default-router 192.168.20.254Router(dhcp-config)#dns-server 192.168.20.254
Router(dhcp-config)#network 192.168.20.0 255.255.255.0Router(dhcp-config)#
Router(config)#ip dhcp pool vlan30Router(dhcp-config)#default-router 10.0.0.1Router(dhcp-config)#dns-server 10.0.0.1Router(dhcp-config)#network 10.0.0.0 255.0.0.0Router(dhcp-config)#
4.创建回程默认路由,指向与路由器相连的交换机接⼝fa0/24地址Router(config)#ip route 0.0.0.0 0.0.0.0 172.16.1.15.保存配置Router#wr
Building configuration...[OK]
三、测试过程
⽤PC机对每个设备进⾏ping
当PC0获得IP地址后,然后分别去PING另外两台获得的地址,能够PING通,说明实验成功
因篇幅问题不能全部显示,请点此查看更多更全内容