IP Masquerade Tutorial for Ubuntu ??

Peter Garrett peter.garrett at optusnet.com.au
Fri May 18 04:54:44 UTC 2007


On Thu, 17 May 2007 20:53:32 -0400
Rashkae <ubuntu at tigershaunt.com> wrote:

> Soo-Hyun Choi wrote:
> > Hi,
> > 
> > I am trying to set up my private network using Ubuntu Feisty as a 
> > gateway. I
> > searched "IP Masquerade Tutorial" over the web and found tons of those.
> > However, it seems that none of them are straightforward to set it up.

[snip]

> Assuming that eth0 is your interent network, and has an IP address like 
> 192.168.0.1 and eth1 is your internet connection
> 
> sudo iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
> sudo echo "1" > /proc/sys/net/ipv4/ip_forward

The line above will not work - "echo" using "sudo" simply prepended like
this will produce an error. See 

https://help.ubuntu.com/community/RootSudo#head-a1a6136e349bca8bd739ef01ebe7a02c65007bd6

Instead, try either

sudo bash -c "echo "1" > /proc/sys/net/ipv4/ip_forward "      or

echo "1" | sudo tee /proc/sys/net/ipv4/ip_forward 

> 
> should do the trick.  You can put those in your /etc/rc.local without 
> the sudo's.

That should work as you say, since /etc/rc.local runs on boot at the end of
runlevel 2 with root privileges, yes  :-)

Peter




More information about the ubuntu-users mailing list