1.固定地址分配
客户端虽然使用dhcp服务器在获取ip,但是我们希望他每一次获取到的IP都是固定的IP。
能够实现的就是服务器端,服务器可以为固定的客户保留固定的IP。
在服务器的配置文件中之名给谁留哪一个就可以了。
1)查看客户机的MAC地址:
[root@client1 ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.25.254.100 netmask 255.255.255.0 broadcast 172.25.254.255
inet6 fe80::5054:ff:fe00:50b prefixlen 64 scopeid 0x20<link>
ether 52:54:00:00:05:0b txqueuelen 1000 (Ethernet)
RX packets 321 bytes 36823 (35.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1633 bytes 105635 (103.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
# eth0的mac地址就是52:54:00:00:05:0b
2)编写服务端的dhcp配置文件:
[root@server ~]# vim /etc/dhcp/dhcpd.conf
# set.
host fantasia {
hardware ethernet 52:54:00:00:05:0b; # 写入指定用户网卡的mac地址
fixed-address 172.25.5.120; # 而且没有在地址池中
}
3)重启服务端dhcp服务:
[root@server ~]# systemctl restart dhcpd.service
4)重启客户端的eth0网卡:
[root@client1 ~]# systemctl restart network
5)查看客户端网络:
[root@client1 ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.25.5.120 netmask 255.255.255.0 broadcast 172.25.5.255
inet6 fe80::5054:ff:fe00:50b prefixlen 64 scopeid 0x20<link>
ether 52:54:00:00:05:0b txqueuelen 10