点击这里查看【如何查询服务器IP与MAC地址】
Server1网络信息如下:
[root@server1 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
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: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:dc:25:fc brd ff:ff:ff:ff:ff:ff
inet 192.168.3.5/24 brd 192.168.3.255 scope global dynamic noprefixroute ens33
valid_lft 1097sec preferred_lft 1097sec
inet6 fe80::7b4c:6610:f082:b301/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 52:54:00:41:ef:64 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:41:ef:64 brd ff:ff:ff:ff:ff:ff
5: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master virbr0 state UNKNOWN group default qlen 1000
link/ether fe:54:00:b3:28:dd brd ff:ff:ff:ff:ff:ff
inet6 fe80::fc54:ff:feb3:28dd/64 scope link
valid_lft forever preferred_lft forever
[root@server1 ~]#
Server2网络信息如下:
[root@server2 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
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: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 52:54:00:b3:28:dd brd ff:ff:ff:ff:ff:ff
inet 192.168.122.2/24 brd 192.168.122.255 scope global noprefixroute ens3
valid_lft forever preferred_lft forever
inet6 fe80::2715:6df7:a342:99f7/64 scope link noprefixroute
valid_lft forever preferred_lft forever
安装命令
yum install -y dhcp
我的服务器已经安装了 dhcp服务,我们来查看一下
[root@server1 ~]# rpm -q dhcp
dhcp-4.4.2-9.uel20.x86_64
需求:把Server2的IP地址与MAC地址绑定
vi /etc/dhcp/dhcpd.conf
在下方添加如下代码
host server2 {
hardware ethernet 52:54:00:b3:28:dd;
fixed-address 192.168.122.2;
}
server2 是服务器名:可自定义
hardware ethernet 52:54:00:b3:28:dd; 52:54:00:b3:28:dd为要绑定的MAC地址
fixed-address 192.168.122.2; 192.168.122.2 为MAC地址分配的IP
systemctl restart dhcpd