• 【Liunx】配置IP地址与MAC地址绑定


    A.查询MAC地址

    点击这里查看【如何查询服务器IP与MAC地址】

    B.绑定前的准备

    1.资源:

    (1) 服务器Server1:192.168.122.1

    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 ~]# 
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25

    (2) 服务器Server1:192.168.122.2

    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
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    2. Server1按照dhcp服务

    安装命令

    yum install -y dhcp
    
    • 1

    我的服务器已经安装了 dhcp服务,我们来查看一下

    [root@server1 ~]# rpm -q dhcp
    dhcp-4.4.2-9.uel20.x86_64
    
    • 1
    • 2

    C.开始绑定操作

    需求:把Server2的IP地址与MAC地址绑定

    1.修改dhcp配置文件

    vi /etc/dhcp/dhcpd.conf
    
    • 1

    在下方添加如下代码

    host server2 {
            hardware ethernet 52:54:00:b3:28:dd;
            fixed-address 192.168.122.2;
    } 
    
    • 1
    • 2
    • 3
    • 4

    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.生效

    systemctl restart dhcpd
    
    • 1
  • 相关阅读:
    深蓝激光slam理论与实践-第一节笔记
    2023品牌新媒体矩阵营销洞察报告:流量内卷下,如何寻找增长新引擎?
    Baumer工业相机堡盟工业相机如何通过BGAPISDK获取相机接口数据吞吐量(C语言)
    我的这段代码为什么总是报错“”is not in list,怎么改呢?
    Spring之IOC
    指针强化与提高
    ubuntu连接蓝牙耳机
    flink核心思想
    剑指 Offer II 021. 删除链表的倒数第 n 个结点【链表】
    2022年杭电多校第四场补题记录
  • 原文地址:https://blog.csdn.net/sinat_36528886/article/details/134394193