[Netkit.users] Accessing internet from a virtual host

Gianni Costanzi gianni.costanzi a gmail.com
Mar 29 Ago 2006 08:54:45 CEST


> I'm planning to use Netkit for my career final
> project. I really need to know if there's a way to get
> a virtual host connected to Internet trough the real
> host.

Sure, set the real host as the default route into the virtual host and
than set up NAT on the real host with iptables. For example, suppose
the real host is connected to the Internet through eth0 and is
connected to the virtual host through tap0 (10.0.0.1); the virtual
host is connected to the real host through its eth0 interface which
has address 10.0.0.2:

virtual host# route add default gw 10.0.0.1

real host# iptables -t nat -I POSTROUTING 1 -o eth0 -j MASQUERADE
real host# iptables -I FORWARD 1 -i tap0 -j ACCEPT
real host# echo "1" > /proc/sys/net/ipv4/ip_forward

Now it should work.. perhaps, if the real host is connected to the
Internet through ADSL, you should add this rule (it must be inserted
before the ACCEPT rule in the forwarding chain):
real host# iptables -I FORWARD 1 -i tap0 -p tcp -m tcp --tcp-flags
SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu

I hope this can help you a bit..
bye

-- 

--------------------------------------------------------------------------------------------------------------
|  Gianni Costanzi (gianni.costanzi a gmail.com)
|       (http://ares.science.unitn.it/~gianni.costanzi/)
|
|  Gentoo Documentation Project (GDP) Member - Italian Translator
|       (http://www.gentoo.org/proj/en/gdp/)
|
|  Free Software Foundation Member #3844 (www.fsf.org)
|
|  Sun Valley in Rock Staff Member (www.sunvalleyinrock.net [/forum])
--------------------------------------------------------------------------------------------------------------


Maggiori informazioni sulla lista Netkit.users