Linux- Routing through a PPP Link

October 2016

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

Related :

This document entitled « Linux- Routing through a PPP Link » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.