配置IP地址与MAC地址绑定
- A.查询MAC地址
- B.绑定前的准备
-
- 1.资源:
-
- [(1) 服务器Server1:192.168.122.1](#(1) 服务器Server1:192.168.122.1)
- [(2) 服务器Server1:192.168.122.2](#(2) 服务器Server1:192.168.122.2)
- [2. Server1按照dhcp服务](#2. Server1按照dhcp服务)
- C.开始绑定操作
A.查询MAC地址
点击这里查看【如何查询服务器IP与MAC地址】
B.绑定前的准备
1.资源:
(1) 服务器Server1:192.168.122.1
Server1网络信息如下:
bash
[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 ~]#
(2) 服务器Server1:192.168.122.2
Server2网络信息如下:
bash
[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
2. Server1按照dhcp服务
安装命令
bash
yum install -y dhcp
我的服务器已经安装了 dhcp服务,我们来查看一下
bash
[root@server1 ~]# rpm -q dhcp
dhcp-4.4.2-9.uel20.x86_64
C.开始绑定操作
需求:把Server2的IP地址与MAC地址绑定
1.修改dhcp配置文件
bash
vi /etc/dhcp/dhcpd.conf
在下方添加如下代码
bash
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
2.生效
bash
systemctl restart dhcpd