VyOS can be configured to use a DHCP server to dynamically allocate IP addresses. The following section will guide you through the process of enabling DHCP for a private network in VyOS.
If you are yet to provision your VyOS instances on the CloudCo Partner platform please follow our Getting Started guide.
Configuring Your DHCP Server
In this example, we wish to allocate private IPs under the subnet 192.168.0.0/24 using DHCP. The VyOS instance should already have private address under this subnet (in this case 192.168.0.1) and be attached to an interface (in this case eth1).
In VyOS, each server is identified using a
shared-network-name. In this case we will call our network
We first tell VyOS that this is the only DHCP server for the specified network:
set service dhcp-server shared-network-name dhcpexample authoritative enable
We then tell it to use this instance (specified by IP) as the default router and dns server:
set service dhcp-server shared-network-name dhcpexample subnet 192.168.0.0/24 default-router 192.168.0.1 set service dhcp-server shared-network-name dhcpexample subnet 192.168.0.0/24 dns-server 192.168.0.1
Finally, we tell VyOS to assign IP addresses to machines for 24 hours and to only allocate in the range 192.168.0.100 to 192.168.0.200:
set service dhcp-server shared-network-name dhcpexample subnet 192.168.0.0/24 lease 86400 set service dhcp-server shared-network-name dhcpexample subnet 192.168.0.0/24 start 192.168.0.100 stop 192.168.0.200
Using Your DHCP Server
To configure other instances to use the DHCP server on your VyOS instance you use the CloudCo Partner platform. Navigate to the Instances screen, click the ⚙ Actions menu next to your instance, and choose Configure.
From the Configure window, under Networking column on the right, add the network interface if required then select DHCP from the drop down menu below it and click Save.
Your instance should now have a private IP allocated on the DHCP subnet within the range specified above. You can check this by using