(九)用armbian做dhcp - ch0769/luyou GitHub Wiki

用armbian做dhcp N1盒子,采用armbian + docker方式做旁路由,一般的教程是: 要么主路由开dhcp,旁路由关dhcp 要么主路由关dhcp,旁路由开dhcp

我的方案是: 主路由DHCP,关掉! 旁路由DHCP, 也关掉! 那谁来做DHCP?用Armbian!!! 这个方案好不好?你用过就知道了

方法:

  1. armbian下安装dnsmasq apt update apt install dnsmasq

  2. 配置 dnsmasq, 修改 /etc/dnsmasq.conf,内容如下(示例): resolv-file=/etc/resolv.conf strict-order interface=eth0 listen-address=127.0.0.1,192.168.3.10 # 注: 192.168.3.10 是Armbian的静态IP bind-interfaces

DHCP地址分配范围(默认分组,走旁路由) 3.100-3.199

dhcp-range=192.168.3.100,192.168.3.199,255.255.255.0,12h

DHCP地址分配范围(直连分组,走主路由)

dhcp-range=tag:direct,192.168.3.50,192.168.3.99,255.255.255.0,infinite

指定走主路由的设备 (set:direct就是把这台设备分配到“直连”这个组)

dhcp-host=11:11:11:11:11:11,mw4530r,192.168.3.91,infinite,set:direct #打印服务器,不需要翻墙 dhcp-host=22:22:22:22:22:22,haier-waterheader,192.168.3.51,infinite,set:direct # 热水器,不需要翻墙

指定固定IP地址的设备

dhcp-host=33:33:33:33:33:33,mypc,192.168.3.199,infinite #台式机,固定ip 199

指定默认网关和DNS(默认分组,走旁路由,3.20是旁路由的地址)

dhcp-option=option:router,192.168.3.20 dhcp-option=option:dns-server,192.168.3.20,192.168.3.1

指定直连组的网关和 DNS (直连分组,走主路由, 3.1 是主路由的地址)

dhcp-option=set:direct,option:router,192.168.3.1 dhcp-option=set:direct,option:dns-server,192.168.3.1

3.管理dnsmasq服务: systemctl enable dnsmasq #启用 systemctl start dnsmasq #启动 systemctl stop dnsmasq #停止 systemctl restart dnsmasq #重启 systemctl disable dnsmasq #禁用