Linux- Routing through a PPP Link

Sharing an Internet connection

This article is intended to allow you to use an Internet connection (e.g making use of the PPP protocol) through the routing of IP packets by the machine connected to the Internet.

Routing of IP packets

Consider the following: a class C network (254 IP),starting at with a subnet mask:
To configure our gateway, you must first know the version of the core: 2.0, 2.1 or 2.2, 2.3 or 2.4.
The tools being are different.
Here is how to proceed under Linux 2.0 kernel:

/sbin/depmod -a
/sbin/modprobe ip_masq_ftp (to route FTP)
/sbin/modprobe ip_masq_irc (to route IRC)
/sbin/modprobe ip_masq_quake (to route Quake game server)
/sbin/modprobe ip_masq_raudio (to route real audio)

Enable forwarding:

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

To route the connection:

ipfwadm -F -a m -S -D

Which means that everything having as source the 192.168..0 network is routed directly to the Internet.
For the Linux kernel 2.1 and 2.2, the procedure is almost identical, simply change ipfwadm by ipchains.

ipchains -A forward -s -d -j MASQ

Under the Linux kernel 2.3 and 2.4 the procedure is almost identical, simply change ipfwadm by iptables.

iptables -A POSTROUTING -t nat -o ppp0 -j MASQUERADE

Orginal document published by Rémy Pouchain on

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
This document, titled « Linux- Routing through a PPP Link », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (