NTD TCNA DAY05
1 案例1:基于全局的DHCP配置
1.1 问题
基于全局配置DHCP,要求如下。
- 地址池:192.168.1.0/24
- 网 关:192.168.1.254
- D N S:8.8.8.8
- 租 约:3天
1.2 方案
使用eNSP搭建实验环境,如图-1所示。
图-11.3 步骤
实现此案例需要按照如下步骤进行。
1)在路由器上配置DHCP
[dhcp]ip pool pool_tedu //创建DHCP地址池
[dhcp-ip-pool-pool_tedu]network 192.168.1.0 mask 24 //指定网段信息
[dhcp-ip-pool-pool_tedu]gateway-list 192.168.1.254 //指定网关地址
[dhcp-ip-pool-pool_tedu]dns-list 8.8.8.8 //指定DNS服务器地址
[dhcp-ip-pool-pool_tedu]lease day 3 //指定租约
2)开启DHCP
[dhcp]dhcp enable //开启DHCP服务
3)在接口上启用DHCP
[dhcp]int g0/0/0
[dhcp-GigabitEthernet0/0/0]ip add 192.168.1.254 24
[dhcp-GigabitEthernet0/0/0]dhcp select global //启用DHCP全局模式
4)验证
主机A的配置如图-2所示。
图-2
查看获取的IP如图-3所示。
图-3
同样查看主机B的配置,验证主机A可以ping通主机B。
2 案例2:基于接口的DHCP配置
2.1 问题
基于接口配置DHCP,要求如下。
- 地址池:192.168.1.0/24
- 网 关:192.168.1.254
- D N S:8.8.8.8
- 租 约:3天
- 设置保留地址:192.168.1.200、192.168.1.253
2.2 方案
使用eNSP搭建实验环境,如图-4所示。
图-42.3 步骤
实现此案例需要按照如下步骤进行。
1)开启DHCP
[dhcp]dhcp enable //开启DHCP服务
2)在接口上启用DHCP
[dhcp]int g0/0/0
[dhcp-GigabitEthernet0/0/0]ip add 192.168.1.254 24
[dhcp-GigabitEthernet0/0/0]dhcp select interface //启用DHCP接口模式
[dhcp-GigabitEthernet0/0/0]dhcp server dns-list 8.8.8.8 //指定DNS服务器地址
[dhcp-GigabitEthernet0/0/0]dhcp server lease day 3 //指定租约时间
[dhcp-GigabitEthernet0/0/0]dhcp server excluded-ip-address 192.168.1.200 192.168
.1.253 //指定排除地址范围
3)验证
主机A获取的IP如图-5所示。
图-5
同样查看主机B的配置,验证主机A可以ping通主机B。
3 案例3:配置DHCP中继
3.1 问题
- 配置DHCP中继,让客户端从DHCP服务器获取地址。
- 客户机可以ping通R1。
3.2 方案
使用eNSP搭建实验环境,如图-6所示。
图-63.3 步骤
实现此案例需要按照如下步骤进行。
1)配置R1
[R1]dis cu
[V200R003C00]
#
sysname R1
#
snmp-agent local-engineid 800007DB03000000000000
snmp-agent
#
clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load portalpage.zip
#
drop illegal-mac alarm
#
set cpu-usage threshold 80 restore 75
#
dhcp enable //启用了DHCP服务
#
ip pool pool_tedu //DHCP地址池信息
gateway-list 192.168.1.254
network 192.168.1.0 mask 255.255.255.0
lease day 3 hour 0 minute 0
dns-list 8.8.8.8
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
local-user admin service-type http
#
firewall zone Local
priority 15
#
interface Ethernet0/0/0
#
interface Ethernet0/0/1
#
interface Ethernet0/0/2
#
interface Ethernet0/0/3
#
interface Ethernet0/0/4
#
interface Ethernet0/0/5
#
interface Ethernet0/0/6
#
interface Ethernet0/0/7
#
interface GigabitEthernet0/0/0 //此接口的DHCP配置信息
ip address 10.10.10.1 255.255.255.0
dhcp select global
#
interface GigabitEthernet0/0/1
#
interface NULL0
#
ip route-static 192.168.1.0 255.255.255.0 10.10.10.2
#
user-interface con 0
authentication-mode password
user-interface vty 0 4
user-interface vty 16 20
#
wlan ac
#
return
2)配置R2
[R2]dis cu
[V200R003C00]
#
sysname R2
#
snmp-agent local-engineid 800007DB03000000000000
snmp-agent
#
clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load portalpage.zip
#
drop illegal-mac alarm
#
set cpu-usage threshold 80 restore 75
#
dhcp enable
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
local-user admin service-type http
#
firewall zone Local
priority 15
#
interface Ethernet0/0/0
#
interface Ethernet0/0/1
#
interface Ethernet0/0/2
#
interface Ethernet0/0/3
#
interface Ethernet0/0/4
#
interface Ethernet0/0/5
#
interface Ethernet0/0/6
#
interface Ethernet0/0/7
#
interface GigabitEthernet0/0/0
ip address 10.10.10.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 192.168.1.254 255.255.255.0
dhcp select relay //启用DHCP中继代理模式
dhcp relay server-ip 10.10.10.1 //指定DHCP服务器地址
#
interface NULL0
#
user-interface con 0
authentication-mode password
user-interface vty 0 4
user-interface vty 16 20
#
wlan ac
#
return
3)验证
主机获取的IP如图-7所示。
图-7
验证主机可以ping通R1,如图-8所示。
图-8
4 案例4:交换机配置DHCP服务器
4.1 问题
- 配置两个地址池:192.168.1.0/24和192.168.2.0/24
- 配置两个VLAN:VLAN 10和VLAN 20
- 将四台主机分别加入VLAN
- 自动获取IP地址,确保全网互通
4.2 方案
使用eNSP搭建实验环境,如图-9所示。
图-94.3 步骤
实现此案例需要按照如下步骤进行。
1)配置DHCP服务器
[SW3]dis cu
#
sysname SW3
#
vlan batch 10 20
#
cluster enable
ntdp enable
ndp enable
#
drop illegal-mac alarm
#
dhcp enable
#
diffserv domain default
#
drop-profile default
#
ip pool pool1 //DHCP地址池信息
gateway-list 192.168.1.254
network 192.168.1.0 mask 255.255.255.0
lease day 7 hour 0 minute 0
dns-list 8.8.8.8
#
ip pool pool2 //DHCP地址池信息
gateway-list 192.168.2.254
network 192.168.2.0 mask 255.255.255.0
lease day 7 hour 0 minute 0
dns-list 8.8.8.8
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password simple admin
local-user admin service-type http
#
interface Vlanif1
#
interface Vlanif10
ip address 192.168.1.254 255.255.255.0
dhcp select global //启用DHCP全局模式
#
interface Vlanif20
ip address 192.168.2.254 255.255.255.0
dhcp select global //启用DHCP接口模式
#
interface MEth0/0/1
#
interface GigabitEthernet0/0/1 //此接口设置为trunk模式
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
interface GigabitEthernet0/0/3
#
interface GigabitEthernet0/0/4
#
interface GigabitEthernet0/0/5
#
interface GigabitEthernet0/0/6
#
interface GigabitEthernet0/0/7
#
interface GigabitEthernet0/0/8
#
interface GigabitEthernet0/0/9
#
interface GigabitEthernet0/0/10
#
interface GigabitEthernet0/0/11
#
interface GigabitEthernet0/0/12
#
interface GigabitEthernet0/0/13
#
interface GigabitEthernet0/0/14
#
interface GigabitEthernet0/0/15
#
interface GigabitEthernet0/0/16
#
interface GigabitEthernet0/0/17
#
interface GigabitEthernet0/0/18
#
interface GigabitEthernet0/0/19
#
interface GigabitEthernet0/0/20
#
interface GigabitEthernet0/0/21
#
interface GigabitEthernet0/0/22
#
interface GigabitEthernet0/0/23
#
interface GigabitEthernet0/0/24
#
interface NULL0
#
user-interface con 0
user-interface vty 0 4
#
return
2)配置SW1
[SW1]dis cu
#
sysname SW1
#
vlan batch 10 20
#
cluster enable
ntdp enable
ndp enable
#
drop illegal-mac alarm
#
diffserv domain default
#
drop-profile default
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password simple admin
local-user admin service-type http
#
interface Vlanif1
#
interface MEth0/0/1
#
interface Ethernet0/0/1
port link-type access
port default vlan 10
#
interface Ethernet0/0/2
port link-type access
port default vlan 10
#
interface Ethernet0/0/3
#
interface Ethernet0/0/4
#
interface Ethernet0/0/5
#
interface Ethernet0/0/6
#
interface Ethernet0/0/7
#
interface Ethernet0/0/8
#
interface Ethernet0/0/9
#
interface Ethernet0/0/10
#
interface Ethernet0/0/11
#
interface Ethernet0/0/12
#
interface Ethernet0/0/13
#
interface Ethernet0/0/14
#
interface Ethernet0/0/15
#
interface Ethernet0/0/16
#
interface Ethernet0/0/17
#
interface Ethernet0/0/18
#
interface Ethernet0/0/19
#
interface Ethernet0/0/20
#
interface Ethernet0/0/21
#
interface Ethernet0/0/22
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
interface GigabitEthernet0/0/2
#
interface NULL0
#
user-interface con 0
user-interface vty 0 4
#
return
3)配置SW2
[SW2]dis cu
#
sysname SW2
#
vlan batch 10 20
#
cluster enable
ntdp enable
ndp enable
#
drop illegal-mac alarm
#
diffserv domain default
#
drop-profile default
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password simple admin
local-user admin service-type http
#
interface Vlanif1
#
interface MEth0/0/1
#
interface Ethernet0/0/1
port link-type access
port default vlan 20
#
interface Ethernet0/0/2
port link-type access
port default vlan 20
#
interface Ethernet0/0/3
#
interface Ethernet0/0/4
#
interface Ethernet0/0/5
#
interface Ethernet0/0/6
#
interface Ethernet0/0/7
#
interface Ethernet0/0/8
#
interface Ethernet0/0/9
#
interface Ethernet0/0/10
#
interface Ethernet0/0/11
#
interface Ethernet0/0/12
#
interface Ethernet0/0/13
#
interface Ethernet0/0/14
#
interface Ethernet0/0/15
#
interface Ethernet0/0/16
#
interface Ethernet0/0/17
#
interface Ethernet0/0/18
#
interface Ethernet0/0/19
#
interface Ethernet0/0/20
#
interface Ethernet0/0/21
#
interface Ethernet0/0/22
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
interface GigabitEthernet0/0/2
#
interface NULL0
#
user-interface con 0
user-interface vty 0 4
#
return
4)验证
四台主机获取的IP地址分别为:192.168.1.253、192.168.1.252、192.168.2.253、192.168.2.252。
四台主机均可以互相ping通。