Showing posts with label LNUX IP TABLES. Show all posts
Showing posts with label LNUX IP TABLES. Show all posts

Tuesday, 10 May 2011

Linux Internet Gateway Server Setup

Setup Netwok Diagram.



Linux Server:

eth0 ( External Interface )
eth1 ( Internal Netwok Interface) ( 192.168.1.X series )

Step 1. Enable ip nat in linux kernel.

"echo '1' > /proc/sys/net/ipv4/ip_forward"

Step 2. Assign IP address to eth0 and eth1
-------------------------------------------------------
/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
ONBOOT=yes
IPADDR=xxx.xxx.xxx.xxx
NETMASK=255.255.255.xxx
GATEWAY=xxx.xxx.xxx.xxx
TYPE=Ethernet
BOOTPROTO=static
HWADDR=00:11:5B:F6:E2:5D
-------------------------------------------------------
-------------------------------------------------------
/etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1
ONBOOT=yes
IPADDR=192.168.1.1
NETMASK=255.255.255.0
TYPE=Ethernet
BOOTPROTO=static
HWADDR=00:29:5X:FG:32:8S
-------------------------------------------------------

"service network restart"

Step 3. Set iptable commands.

"iptables -F"
"iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE"
"iptables --append FORWARD --in-interface eth1 -j ACCEPT"

Step 4. Add the above entries to /etc/rc.local file.

/etc/rc.local

/sbin/iptables -F 2>/dev/null
/sbin/iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE 2>/dev/null
/sbin/iptables --append FORWARD --in-interface eth1 -j ACCEPT 2>/dev/null

========================================================================