Gateway server configuration is the easiest thing in Linux server configuration. For this we have to follow the following steps.
1. We have to ensure that the server computer two NICs. Then we have to configure the NICs. I think most of us can do this thing. To configure interface eth1 we have to create a file /etc/sysconfig/network-scripts/ifcfg-eth1 (If there is no such file; if there exist the file then we have to edit this file) as follows:
vi /etc/sysconfig/network-scripts/ifcfg-eth1
# Intel Corporation 82573E Gigabit Ethernet Controller (Copper)
DEVICE=eth1
BOOTPROTO=static
HWADDR=12:34:56:78:9A:BC
IPADDR=192.168.100.1
NETMASK=255.255.255.0
Here the network is 192.168.100.0/24
This is the LAN side.
We will configure WAN side at eth0 with the following command:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
# Intel Corporation 82573E Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=static
HWADDR=12:34:56:78:9A:BC
IPADDR=221.120.96.233
NETMASK=255.255.255.224
Now we will restart the interfaces.
/etc/init.d/network restart
2. Now we have to do minimum two things.
* IP forwarding
* NAT (Network Address Translation)
3. For IP forwarding we can chose any one procedure as follows:
* Procedure 1: We can write only one command as follows :
# echo 1>/proc/sys/net/ipv4/ip_forward
and then entry this line at /etc/rc.local file.
* Procedure 2: We can edit the /etc/sysctl.conf file and do there we will change the value 0 of net.ipv4.ip_forward to 1.
# vi /etc/sysctl.conf
net.ipv4.ip_forward=1
Then we have to restart the file with the following command:
# sysctl -p
4. For NAT we can add only two line at /etc/rc.local file:
iptables -t nat -F
iptables -t nat -A POSTROUTING -s 192.168.100.0/24 -d 0/0 -j SNAT –to-source 221.120.96.233
Thats all. Our Gateway server is configured. Now we can check whether its working or not.
Any suggestions ?