DHCP 动态给IP地址及DNS技术
自动获取IP地址技术之DHCP
实验:把路由器当做1台DHCP服务器,来自动给各个手机终端分配IP地址,使3台电脑自动获取IP地址
- 给路由器手动配IP地址:192.168.1.1(专业设备需要手动配置地址)
<Huawei>sy
Enter system view, return user view with Ctrl+Z.
[Huawei]int
[Huawei]interface g0/0/0
[Huawei-GigabitEthernet0/0/0]ip ad 192.168.1.1 255.255.255.0
[Huawei-GigabitEthernet0/0/0]
- 配置网络地址分静态(手工配置)和DHCP(动态拿到IP地址),让路由器给客户端送地址
- 要开通DHCP的相关功能(客户终端N台设备都可以拿到ip地址),由路由器充当DHCP服务器,给客户端分配IP地址
<Huawei>sy
Enter system view, return user view with Ctrl+Z.
[Huawei]dhcp enable
//①开通激活DHCP功能
Info: The operation may take a few seconds. Please wait for a moment.done.
/*路由器有多个接口,就要选定目的接口实现DHCP功能*/
//给g0/0/0开通分配IP地址的功能
<Huawei>sy //试读
Enter system view, return user view with Ctrl+Z.
[Huawei]int
[Huawei]interface g0/0/0 //进入目标接口
[Huawei-GigabitEthernet0/0/0]dhcp select int
[Huawei-GigabitEthernet0/0/0]dhcp select interface //选择激活指定的接口
[Huawei-GigabitEthernet0/0/0]
//到此为止就可自动获取IP地址了
相同操作后就可获取IP地址了
DHCP自动获取IP地址步骤:
/*进入试读:*/
<Huawei>sy
Enter system view, return user view with Ctrl+Z.
/*选择接口*/
[Huawei]int g0/0/0
/*指定接口配地址:*/
[Huawei-GigabitEthernet0/0/0]ip ad 192.168.1.1 255.255.255.0
/*开通激活:*/
[Huawei]dhcp enable
/*进入接口:*/
[Huawei]interface g0/0/0
/*选定该接口:*/
[Huawei-GigabitEthernet0/0/0]dhcp select interface
/*退出保存:*/
[Huawei]quit
<Huawei>save
测试:用PC1去pingPC2和PC3是通的
PC>ping 192.168.1.253
Ping 192.168.1.253: 32 data bytes, Press Ctrl_C to break
From 192.168.1.253: bytes=32 seq=1 ttl=128 time=47 ms
From 192.168.1.253: bytes=32 seq=2 ttl=128 time=16 ms
From 192.168.1.253: bytes=32 seq=3 ttl=128 time=15 ms
From 192.168.1.253: bytes=32 seq=4 ttl=128 time=47 ms
From 192.168.1.253: bytes=32 seq=5 ttl=128 time=31 ms
--- 192.168.1.253 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 15/31/47 ms
PC>ping 192.168.1.252
Ping 192.168.1.252: 32 data bytes, Press Ctrl_C to break
From 192.168.1.252: bytes=32 seq=1 ttl=128 time=31 ms
From 192.168.1.252: bytes=32 seq=2 ttl=128 time=31 ms
From 192.168.1.252: bytes=32 seq=3 ttl=128 time=47 ms
From 192.168.1.252: bytes=32 seq=4 ttl=128 time=47 ms
From 192.168.1.252: bytes=32 seq=5 ttl=128 time=31 ms
--- 192.168.1.252 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 31/37/47 ms
DNS解析网址技术
实验:通过ping网址
来实现ping通目标IP地址?
网址也叫域名,如:www.baidu.com,域名的服务器也是IP地址
通过域名来访问IP地址,需要1台DNS服务器,来实现域名解析;把网址变成对应的IP地址
电脑ping网址ping不通到通实验步骤:开通DNS服务器功能
对server3进行配置:
1. 设置好DNS服务器参数
就可以ping www.baidu.con访问到192.168.1.253的IP地址
2. 服务器(与路由器一样都需要配IP地址才可联通:192.168.1.100)
此时,pingBAIDU未通,DNS服务器的地址是空的,PC并不知DNS服务器地址的存在
3. 在有DHCP服务的基础上开通DNS服务器的功能命令
(给路由器
配置DHCP时候再加1条命令)
<Huawei>sy
Enter system view, return user view with Ctrl+Z.
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]DHCP server dns
[Huawei-GigabitEthernet0/0/0]DHCP server dns-list 192.168.1.100
[Huawei-GigabitEthernet0/0/0]dhcp server dns-list 192.168.1.100
Info:Part of the domain-name-server IP has already exist.
//就可以获取DNS服务器地址了
原理:
1、PC机访问网址
2、先把网址送给服务器192.168.1.100进行解析
3、服务器把网址转换IP:服务器里的有了百度192.168.1.253IP地址记录,就帮百度解析成IP192.168.1.253了
PC>ping www.baidu.com
host www.baidu.com unreachable
出现这种提示需要重新启动,重新获取即可
出来了: \color{red}{出来了:} 出来了:
PC>ping www.baidu.com
Ping www.baidu.com [192.168.1.253]: 32 data bytes, Press Ctrl_C to break
From 192.168.1.253: bytes=32 seq=1 ttl=128 time=47 ms
From 192.168.1.253: bytes=32 seq=2 ttl=128 time=32 ms
From 192.168.1.253: bytes=32 seq=3 ttl=128 time=31 ms
From 192.168.1.253: bytes=32 seq=4 ttl=128 time=47 ms
From 192.168.1.253: bytes=32 seq=5 ttl=128 time=31 ms
--- 192.168.1.253 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 31/37/47 ms