05 Apr

Sharing an Internet Connection from A Linux System using IPTables

To setup internet connection sharing in Linux system using IPTables

Enable IP forwarding

Run as root

sysctl -w net.ipv4.ip_forward=1

To enable it in system startup, edit the file /etc/sysctl.conf and set

net.ipv4.ip_forward = 1


Run command as root

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
service iptables save


The configuration should be like this


Connected to the internet provider
IP :

Internet Connected System

eth0 (LAN Card 1)

Connected to router

  • IP :
  • Netmask :
  • Gateway : (IP of the router)

eth1 (LAN Card 2)

Connected to the other system

  • IP : (Not the same network as the first card)
  • Netmask :
  • Gateway : (IP of the router)

Second System

LAN Card connected to the first system

  • IP :
  • Netmask :
  • Gateway : (IP of the second Card in the first system)


Linux networks is not a subject I am an expert on. So take my advice with a pinch of salt. The above procedure worked for me – so I am documenting it here so that I can reproduce it if I need it someday. YMMV.

This method can be used to share an internet connection from a Linux system(I used Fedora Core 6, but it should work on other distibutions that support iptables) to a Windows system. I used Windows XP.


Some results of various commands are shown here. Check to see if it matches the result on your system.

# iptables -t nat -L POSTROUTING
target     prot opt source               destination
MASQUERADE  all  --  anywhere             anywhere
# cat /proc/sys/net/ipv4/ip_forward
# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination


09 Mar

Download Entire Folder using Wget Command in Linux

wget -m http://www.tldp.org/HOWTO/Serial-Programming-HOWTO/

-m, –mirror
shortcut for -N -r -l inf –no-remove-listing.

wget -H -r --level=1 -k -p http://www.tldp.org/HOWTO/Serial-Programming-HOWTO/

-r, –recursive
Specify recursive download.
-l, –level=NUMBER
Maximum recursion depth (inf or 0 for infinite).
-k, –convert-links
Make links in downloaded HTML point to local files.
-p, –page-requisites
Get all images, etc. needed to display HTML page.

Original Article
wget Manual