联网固化IP子网网关dns,关闭VMware的dhcp服务
安装dhcp
更改配置文件
vim /etc/dhcp/dhcpd.conf
subnet 分配的网段 netmask 子网掩码 {
option routers 网关;
option domain-name-servers dns;
range 192.168.254.100 192.168.254.200;
host pc1(重命名) {
hardware ethernet MAC地址;
fixed-address 设置保留的IP;
}
启动 network
关闭防火墙
#### DHCP工作原理(DHCP工作过程)四次握手
[root@localhost ~]# dhclient -d ens33
**-d=调试 给ens33网卡获取地址显示过程。**
Internet Systems Consortium DHCP Client 4.1.1-P1
Copyright 2004-2010 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
Listening on LPF/eth0/00:0c:29:ae:1c:25
Sending on LPF/eth0/00:0c:29:ae:1c:25
Sending on Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 8
**DISCOVER(发现) 发广播给每个接口发一份 (广播)**
DHCPOFFER from 192.168.4.11
**OFFER(提供) DHCP收到了发出指示 给你一个ip (单播**)
DHCPREQUEST on eth0 to 255.255.255.255 port 67
**REQUEST(选用) 选用了这个ip地址 (广播)**
DHCPACK from 192.168.4.11
**ACK(确认) 确认 (单播)**
bound to 192.168.4.254 — renewal in 9220 seconds.
……
#### /etc/hosts 文件
用途:保存主机名与 IP 地址的映射记录
hosts 文件和 DNS 服务器的比较
默认情况下,系统首先从 hosts 文件查找解析记录
hosts 文件只对当前的主机有效
hosts 文件可减少 DNS 查询过程,从而加快访问速度