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
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 1 comment… read it below or add one }
Here is my take on Internet Connection Sharing using iptables