How to set up DHCP and NAT on Vyatta router

Vyatta is a feature-rich enterprise class software router. You can download a free community version of Vyatta. Vyatta router can easily be built on a physical machine via a well-packaged LiveCD, or on a VMware virtual machine (VM) via a custom virtual appliance. As a ready-made software router, Vyatta can be configured extremely easily to run as a NAT gateway with DHCP, DNS and NAT functionality.

The following guide shows you how to set up DHCP and NAT on Vyatta router by using Vyatta's command line interface (CLI).

I assume that you already installed Vyatta on your machine or VM. I also assume that the router has two interfaces: eth0 (WAN interface) and eth1 (LAN interface). Now proceed as follows.

Log in to the Vyatta router, and type the following commands.

$ install image
$ reboot

Now, enter the Vyatta's CLI by running:

$ configure

At this point, you are in the Vyatta configuration mode, and are ready to use Vyatta's CLI commands. Run the rest in configuration mode.

$ set system host-name [router-host-name]
$ set system domain-name [router-domain-name]
$ set interfaces ethernet eth0 address dhcp
$ set interfaces ethernet eth1 address

In the above, you set the name of the router, and configure router's two interfaces. The WAN interface (eth0) uses DHCP to get its IP address assigned dynamically, while the LAN interface (eth1) gets its IP address ( statically assigned.

In the next set of commands, you will then configure the DHCP service of the router for internal networks: DHCP address range (from to, and returned DNS server (, and default gateway (

$ set service dhcp-server shared-network-name PRIVATE subnet start stop
$ set service dhcp-server shared-network-name PRIVATE subnet dns-server
$ set service dhcp-server shared-network-name PRIVATE subnet default-router

Note that you don't have to specify which interface the DHCP service is associated with. The interface to use for DHCP service is automatically determined by the subnet associated with DHCP service. In this example, since the DHCP's subnet is connected to eth1, the DHCP service will be running on eth1.

Once DHCP has been configured, you will then go ahead and set up NAT on the router.

$ set nat source rule 10 outbound-interface eth0
$ set nat source rule 10 source address
$ set nat source rule 10 translation address masquerade

Finally, you must commit your configuration, and save it permanently before exiting. The saved configuration will be stored in /config/config.boot file.

$ commit
$ save
$ exit
$ reboot

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

One thought on “How to set up DHCP and NAT on Vyatta router

  1. this works, thank you!

    PS: it reads like enabling the dhcp server is required for enabling nat, but I think that is not the case.

Leave a comment

Your email address will not be published. Required fields are marked *