how can i setup my ubuntu machine as a router

ZIYAD A. M. AL-BATLY zamb at saudi.net.sa
Fri Jul 1 14:39:23 UTC 2005


On Fri, 2005-07-01 at 17:57 +0500, Mustafa Abbasi wrote:
> my ubuntu machine connects directly to internet via a cable modem.
> i wanted to share my  connection wth the other computer in the house.
> one is an xbox and one is a windows xp machine.
> in winxp i just enable internet coneection sharing.
> how do i do it here.
Here's a dirty, manual, and fast (but definitely not professional)
solution:

sudo sh -c 'echo 1 >/proc/sys/net/ipv4/ip_forward'
sudo iptables -P FORWARD ACCEPT &&
sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE


In the above, I assumed your Internet connection is "ppp0", change it as
you wish (it might be "ppp1", "eth0", or "eth1").

Now, your Ubuntu system is a gateway.  Just point the other PCs for this
one as their gateway.  Also, setup the DNS on the other system manually.
You'll find your DNS setting by running "cat /etc/resolv.conf | grep
'^nameserver'".


Hope this helps you (and wait a little bit for more professional
solution with DHCP.  I'm sure someone will tell us how).
Ziyad.




More information about the ubuntu-users mailing list