vyos有两个网卡,分别是eth0和eth1,IP分别是10.1.1.175和10.222.222.1(掩码都是/24),分别用于连接外网和内网。
需求:eth1网卡配置dhcp,分配范围是11-254,dns是10.222.222.1。
进入配置模式
configure
指定dhcp网关
set service dhcp-server shared-network-name dhcp subnet 10.222.222.0/24 default-router 10.222.222.1
指定dhcp dns,如有多个dns可配置多次
set service dhcp-server shared-network-name dhcp subnet 10.222.222.0/24 dns-server 10.222.222.1
指定租约时间,单位是秒,默认86400
set service dhcp-server shared-network-name dhcp subnet 10.222.222.0/24 lease 3600
指定dhcp地址池起始地址
set service dhcp-server shared-network-name dhcp subnet 10.222.222.0/24 range exclude start 10.222.222.11
指定dhcp地址池终止地址
set service dhcp-server shared-network-name dhcp subnet 10.222.222.0/24 range exclude stop 10.222.222.254
提交及保存
commit
save
至此全部完成,设备接入到同一个广播域即可获取地址,下图以Win7为例,可看到获取到了10.222.222.11的地址。
下面是配置信息
vyos@vyos# show service dhcp-server
shared-network-name dhcp {
subnet 10.222.222.0/24 {
default-router 10.222.222.1
dns-server 10.222.222.1
lease 3600
range exclude {
start 10.222.222.11
stop 10.222.222.254
}
}
}