Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I setup a centos server as Router with 2 Nic's..eth1 for LAN and eth0 for Wan interface. But my modem/router is configured as a router and not in bridge mode. I need to make my linux system as the router and default gateway and have the advantage of iptables firewall etc rather than the modem/router being the internet gateway for my LAN.

My server ip is Modem?router is Lan ....etc..etc..

Please, how can this setup on my server and LAN ???? Waiting for a detailed answer...

share|improve this question
Are you just re-asking the same question you asked 4 hours ago with less detail?… – Zoredache Jul 26 '11 at 6:39
Sorry...but I have rephrased my question and I did not get an answer from superuser – shels Jul 26 '11 at 6:44
Waiting for detailed answer, need to have detailed question. Put more detailed in you question, and you'll get more efficient answer ;) – Anarko_Bizounours Jul 26 '11 at 6:50

To allow your system to act as a router you need to enable IP forwarding.

You can do instantly with this with

sudo echo 1 > /proc/sys/net/ipv4/ip_forward

This will only enable routeing until the next time the system is restarted. To ensure that the system routes permanently edit /etc/sysctl.conf and ensure there is a line that says

net.ipv4.ip_forward = 1
share|improve this answer
I have enabled ipforwarding etc..etc and my network is working fine...the existing setup used a bridged modem but now I have a router/modem..I want my Centos server to act as gateway rather than the modem/router as gateway.. – shels Jul 26 '11 at 6:43

I'd recommend 2 HOWTOs:

This one: will let you configure your NAT (look for the section "I just want masquerading! Help!").

This one will give you some basics on networking:

The HOWTOs are rather old (made for 2.4 kernels), but they are still relevant.

share|improve this answer
Sorry..this is not a question about NAT etc,...I think I need to create 2 for my server and modem/router and another subnet for my LAN through my switch.. – shels Jul 26 '11 at 7:15
If you want to communicate with Internet you need either routable IP address for each host ( is not routable) or you need NAT. If you put your hosts in network A, but your WAN modem in netowrk B you'd need to set up routing on the WAN or it would not know to deliver packets to network A through your server's interface in network B. – Paweł Brodacki Jul 26 '11 at 8:13
My modem router is which is connected to eth0 with ip and my LAN (eth1) is and one of my client is ip iptabes to MASQUERADE and got it working...So LAN and WAN should be on different subnets...that is the point to be remembered – shels Jul 26 '11 at 13:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.