Linux Box as a Router

Operating System: Centos 6.3

You need two network cards on your Linux box. Iptables are then used to share the WAN interface of the box onto the Local Interface where network users are connected to.

The setup should be;

  • Internal LAN network card (eth1) assigned a static private IP address (192.168.2.1).
  • External network card (eth0) assigned a public IP address and connected to the ISP. In our case we have assigned it a private IP address for the purpose of demonstration (192.168.1.5)

Configurations:

ENABLE PACKET FORWARDING

By default this is disabled.
Edit /etc/sysctl.conf
Change the statement in the file reading ;
---------------------------------------------------------------------
Net.ipv4.conf.default.forwarding=0
--------------------------------------------------------------------

To;
-------------------------------------------------------------------
Net.ipv4.conf.default.forwarding=1
---------------------------------------------------------------------
And then save the file and restart your network using;

[root@telweb]# Service network restart 

ENABLE MASQUERADING/ NAT;

This is sharing of the internet connection from the WAN side with a public IP to the LAN with Private IPs which are not routable on the internet

[root@telweb]# service iptables stop
[root@telweb]# iptables –t nat –APOSTROUTING -0 eth0 –j MASQUERADE
[root@telweb]# service iptables save
[root@telweb]# service iptables restart

Configure iptables to always start boot time
[root@telweb]# chkconfig iptables on

Client/ end user access configurations in order to access internet via the box
Configure a static IP, subnet mask, default gateway and DNS server.

Done!!

Comments

Popular posts from this blog

MPLS-VPN

MPLS - L2MPLS / L2 Circuits

Linux Box as a DHCP Server