[Netkit.users] Accesing Internet from a virtual machine

Gianni Costanzi gianni.costanzi a gmail.com
Mar 5 Set 2006 10:26:09 CEST


On 9/5/06, Emilia Rodriguez <emi_grz a yahoo.es> wrote:
> Hi everybody:
> I  would like to know how can I connect the virtual machine with Internet
> through the host machine using Netkit?
>
> For that, I did this:
>     In the host machine:
>         vstart pc1 eth0=tap,10.0.0.1,10.0.0.2

Since I have really few time to answer, I'll copy & paste an answer to
a similar question that I already gave on this mailing list:

> 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 ppp0 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
virtual host# vi /etc/resolv.conf (write into this file the contents
of /etc/resolv.conf of your real host)

real host# iptables -t nat -I POSTROUTING 1 -o ppp0 -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'm sorry if this is not very clear, but I'm really in a hurry now!
Hope it helps 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