Setting up NAT

Current NAT server is natrium.club.cc.cmu.edu

Setting up NAT gateway

See https://wiki.club.cc.cmu.edu/org-auth/ccwiki/natrium.club.cc.cmu.edu

See http://www.bctes.com/nat-linux-iptables.html

Ensure that machine has 2 NIC.

In this guide eth0 is external and eth1 is internal

Modify /etc/sysctl.conf, uncomment:

net.ipv4.ip_forward=1

Modify /etc/rc.local, add:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth1 -j ACCEPT

Execute

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth1 -j ACCEPT

Change <private address> to local address

ifconfig eth1 <private address>

Modify /etc/network/interfaces, add:

# nat interface
auto eth1
iface eth1 inet static
address <private address>
netmask 255.255.255.0 

Adding machines to NAT

Assuming you want to add br1 to natrium as 10.0.2.2

Temporary

ifconfig eth1 10.0.2.2 netmask 255.255.255.0 broadcast 10.0.2.255
route add default gw 10.0.2.1 br1

Permanent

Modify br<interface> in /etc/network/interfaces:

auto br<interface>
iface br<interface> inet static
        address 10.0.2.2 
        netmask 255.255.255.0
        network 10.0.2.0
        broadcast 10.0.2.255
        gateway 10.0.2.1
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 128.237.157.12 128.237.157.14
        dns-search club.cc.cmu.edu
        bridge_ports eth<interface#>


CategoryServices CategoryClubServices

Services/NAT (last edited 2013-10-27 04:27:49 by scgruber@CLUB.CC.CMU.EDU)