NAT Configuration in Ubuntu Server 8.10
Set your static IP configurations on eth0 and eth1.
Make eth0 your primary or outside interface.(internet) Set eth1 to desired address pool to be used as the default route for dhcp clients.(switch) Do not specify a default gateway for eth1, only eth0.
Edit these settings in the /etc/network/interfaces
See example below:
# The primary network interface (Public)
auto eth0
iface eth0 inet static
address 87.65.23.70
netmask 255.255.255.224
network 87.65.23.64
broadcast 87.65.23.95
gateway 87.65.23.65
# The secondary network interface (Private)
auto eth1
iface eth1 inet static
address 192.168.3.1
netmask 255.255.255.0
network 192.168.3.0
broadcast 192.168.3.255
Now configure your DHCP settings accordingly. Here is what I did:
Uncomment: server-identifier "hostname";
subnet 192.168.3.0 netmask 255.255.255.0 {
range 192.168.3.2 192.168.3.254;
option domain-name-servers 192.168.3.1;
option domain-name "hostname";
option routers 192.168.3.1;
option broadcast-address 192.168.3.255;
default-lease-time 600;
max-lease-time 7200;
}
Now you should be able to pick up addresses from your server; however, clients connected will not have internet access. This is because NAT is not enabled. Linux or in this case Ubuntu calls this masquerading.
Two lines of code does this for us, however, it must be run in a script every time the server starts up.
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Run the two above lines for testing. Remember to prefix with sudo to run as root if you aren't logged in as root.
If all is well, add the lines to /etc/rc.local and then add the file to start at boot by running:
chmod +x /etc/rc.local
Test by restarting and release renewing a client and checking for internet access.
Worked for me so I hope this works for you.
Let me know how it goes or if you have more questions.
-Nausser
|