nixCraft Poll

Topics

Howto Setup Linux as router for ppp dial up (PSTN/ISDN) connections

Posted by Vivek Gite [Last updated: November 8, 2006]

This step by step howto will help you to setup Linux as router only in two (2) minutes. I'm assuming that your setup is as follows:

(A) You are using RedHat Linux, FC linux/Debian Linux (this should work with ALL Other distros as well :D )

(B) ppp0 is internet interface (connected to Modem for example) and eth0 connected to your internal lan (connected to your HUB/Switch for example)

My Linux  --> eth0
Box      --> ppp0 (comes up when you dial up into ISP)

Step # 1 Turn on ip forwarding in kernel

1) Open linux kernel configuration file:
# vi /etc/sysctl.conf

2) Add/modify following line:
net.ipv4.ip_forward = 1

Step # 2 Restart network
# /etc/init.d/network restart
OR
# service network restart

(Note first dial to ISP using wvdial or similar program )

Step # 3 Setup IP forwarding and Masquerading (to act as router), you need to use NAT option of iptables as follows:
# iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE
# iptables --append FORWARD --in-interface eth0 -j ACCEPT

Step # 4 You are done! Test it with ping or dig:
# ping your-isp.com
# dig www.nixcraft.com
# dig yahoo.com

Step # 5 Point all client to your eth0 IP address as Router/Gateway.

Step # 6 Put code described in step # 3 to script and call it from /etc/rc.local

Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.

You may also be interested in other helpful articles:

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.