Linux与云计算——第二阶段Linux服务器架设
第二章:DHCP服务器架设
1.配置DHCP服务器
配置DHCP ( Dynamic Host Configuration Protocol ) 服务器. DHCP使用UDP端口67.
[1] 安装并配置DHCP服务器.
[[email protected] ~]# yum -y install dhcp
[[email protected] ~]# vim /etc/dhcp/dhcpd.conf
# 创建一个新文件
# 指定域名
option domain-name "example.com";
# 指定域名服务器的主机名或IP地址
option domain-name-servers 8.8.8.8;
# 默认的租期
default-lease-time 600;
# 最大租期
max-lease-time 7200;
# DHCP服务器被通告为可用服务器
authoritative;
# 指定网络地址和子网掩码;
subnet 192.168.96.0 netmask 255.255.255.0 {
# 指定分配的地址范围
range dynamic-bootp 192.168.96.150 192.168.96.180;
# 指定广播地址
option broadcast-address 192.168.96.255;
# 指定默认网关
option routers 192.168.96.2;
}
[[email protected] ~]# systemctl start dhcpd
[[email protected] ~]# systemctl enable dhcpd
2.配置DHCP客户端
配置DHCP客户端. DHCP客户端使用UDP端口68完成通信.
[1] 在CentOS上,使用下面的方法完成配置. (将配置中enoxxxx修改成你自己的网卡名字)
[[email protected] ~]# nmcli c modify eno16777736 ipv4.method auto
[[email protected] ~]# nmcli c down eno16777736;nmcli c up eno16777736
Connection ‘eno16777736‘ successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/1)
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)
[[email protected] ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:60:33:58 brd ff:ff:ff:ff:ff:ff
inet 192.168.96.150/24 brd 192.168.96.255 scope global dynamic eno16777736
valid_lft 541sec preferred_lft 541sec
inet6 fe80::20c:29ff:fe60:3358/64 scope link
valid_lft forever preferred_lft forever
再来看一下如何在Windows上配置DHCP客户端
选中TCP/IPv4