About Linux FAQ

Browse More FAQs:

Linux Share a Dial Up Internet Connection

Posted by Vivek on Thursday March 6, 08 @6:21 pm

Q. My modem is connected to CentOS Linux server. I'm using wvdial to connect to my ISP; I'd like to connect my laptop via same modem. How do I share a dial up Internet account?

A.. You can use iptables. It supports - IP Masquerading i.e. network address translation (NAT) to share internet.

Connect laptop to Linux box using hub / switch / cross-over Ethernet cable

Dial out using wvdial

Make sure ppp0 is up

Once connected type the following two command at a shell prompt to share ppp0 interface:
# sysctl -w net.ipv4.ip_forward=1
# iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE

You need to add above rules to your existing iptables scripts. You can also create a script call share.ppp0 at /etc/ppp/ip-up.d/ with above two lines. This script run by the pppd after the link is established.
# cat > /etc/ppp/ip-up.d/share.ppp0
Append following code:
#!/bin/sh
sysctl -w net.ipv4.ip_forward=1
iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE
# add other firewall rules below
# ....

Save and close the file.

Client Computer Setup

Login to laptop, set Linux server IP address as default gateway IP. Also setup nameserver IP address (NS1 / NS2). Run ping command to test connectivity:
$ ping google.com
$ ping linux-box.ip
$ nslookup google.com

Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.

Related Linux / UNIX FAQ:

Discussion on This FAQ

  1. Binny V A Says:

    Here is my take on Internet Connection Sharing using iptables

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Please do not use the comment form to ask for help / question. Ask your question on the excellent Linux tech support forum. 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

Tags: , , , , , , , , , , , , ~ Last updated on: March 6, 2008

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