Configuring a DHCP Server
Lets say we now wish to configure a DHCP server, using IP range of 10.0.0.5 to 10.0.0.200, with a default-router address of 10.0.0.1, a DNS server address of 184.108.40.206 (Google) and a shared network name of DHCP-LAN.
set service dhcp-server disabled false edit service dhcp-server shared-network-name DHCP-LAN subnet 10.0.0.0/24 set default-router 10.0.0.1 set dns-server 220.127.116.11 set start 10.0.0.5 stop 10.0.0.200 commit save
Any machines wishing to connect to this need to set their default gateway to the vyos machine (as with nat in the previous section).
route add default gw 10.0.0.1
Say we now wished to set up a static lease, so a machine connecting with mac address 07:ac:29:9a:b0:c0 should be given a static IP of 10.0.0.25 (give this a static mapping name of client1-static).
edit service dhcp-server shared-network-name DHCP-LAN subnet 10.0.0.0/24 static‐mapping client1-static set ip‐address 10.0.0.25 set mac‐address 00:0c:29:9a:70:ca commit save
Setting a domain name
A domain name (say my-network) can also be set up to give to the clients.
set service dhcp-server shared-network-name DHCP-LAN subnet 10.0.0.0/24 domain-name my-network commit save
Setting a lease
A lease time for clients can also be set up (in this example 86400 seconds).
set service dhcp-server shared-network-name DHCP-LAN subnet 10.0.0.0/24 lease 86400 commit save