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.
Now, enter the Vyatta's CLI by running:
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 domain-name [router-domain-name]
$ set interfaces ethernet eth0 address dhcp
$ set interfaces ethernet eth1 address 192.168.1.1/24
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 (192.168.1.1) 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 192.168.1.50 to 192.168.1.100), and returned DNS server (220.127.116.11), and default gateway (192.168.1.1).
$ set service dhcp-server shared-network-name PRIVATE subnet 192.168.1.0/24 dns-server 18.104.22.168
$ set service dhcp-server shared-network-name PRIVATE subnet 192.168.1.0/24 default-router 192.168.1.1
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 192.168.1.0/24 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 source address 192.168.1.0/24
$ 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.
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.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!