Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have the current set up for an embedded environment:

Embedded Target (192.168.0.200) -----> Virtual Machine (VMWare) (2 NIC's - 192.168.0.2 (Target Port) and 192.168.49.69 (NAT Port to host)) ------> NAT on Windows PC ----> internet

What I would like to do is allow the Embedded target to access the internet.

  1. Is this possible?

The Virtual machine can access the internet fine through the NAT on the Virtual machine, I just do not know how to route the embedded target to the internet. There are also other devices on the 192.168.0.x network that access the virtual machine.

Thanks.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

If I understand your question properly, I think you want your VM to act as any gateway/router would. You can do this with IP masquerading.

The necessary configuration for your boxes may vary, but here is a very general example:

VM

Assuming eth0 is your external (NAT) interface with ip 192.168.49.69, you can enable IP masquerading as follows:

$ iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

$ echo 1 > /proc/sys/net/ipv4/ip_forward

Embedded Device

On the embedded device you can statically assign your IP, netmask, default gateway, and DNS resolver as follows:

$ ifconfig eth0 192.168.0.200 netmask 255.255.255.0
$ route add default gw 192.168.0.2
$ echo 'nameserver 8.8.8.8' > /etc/resolv.conf  

These configurations will not persist across reboots. In Ubuntu you will configure your network interface in /etc/network/interfaces and enable IP forwarding in /etc/sysctl.conf. For persisting iptables rules see the linked blog post below for some helpful information.

http://www.cyberciti.biz/faq/how-do-i-save-iptables-rules-or-settings/

share|improve this answer
    
Thanks. The masquerading works fine. –  user626201 Mar 15 '12 at 9:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.