Linux可作為DHCP服務端使用,為同一個網絡下的其它機器動態分配ip。在一些情況下,可以起到很大的作用。
二級標題
安裝dnsmasq
# ubuntu
sudo apt update -y
sudo apt install -y dnsmasq# centos
sudo yum install -y dnsmasq
修改配置文件
sudo vim /etc/dnsmasq.d/10-macvlan-dhcp.conf
interface=enp2s0
dhcp-range=192.168.12.100,192.168.12.200,24h
dhcp-option=3,192.168.12.1/24
dhcp-option=6,192.168.12.1/24
# 參數解釋
# 物理網卡名稱
interface=enp2s0
# 起始ip,結束ip,租賃時長。
dhcp-range=192.168.12.100,192.168.12.200,24h
# 網關地址/掩碼地址
dhcp-option=3,192.168.12.1/24
dhcp-option=6,192.168.12.1/24
重啟dnsmasq服務
sudo systemctl restart dnsmasq
查看運行狀態
sudo systemctl status dnsmasq