Here's how I have my virtual lab setup. I'm just going to show my host and one guest configuration.
My LAN consist of few machines so I assigned a subnet of 192.168.1.33/29. My SOHO router (192.168.1.33) dynamically assigns IP addresses to the local machines. Currently the host machine (Windows) has an IP address of (192.168.1.37):
Ethernet adapter Wireless Network Connection:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Intel(R) PRO/Wireless LAN 2100 3B Mini PCI Adapter
Physical Address. . . . . . . . . : XX-XX-XX-XX-XX-XX
Dhcp Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : 192.168.1.37
Subnet Mask . . . . . . . . . . . : 255.255.255.248
Default Gateway . . . . . . . . . : 192.168.1.33
DNS Servers . . . . . . . . . . . : 10.0.0.138
When I installed the VMware player it automatically created 2 virtual interfaces (VMnet1 & VMnet8) in my host machine. It randomly assigned IP address to both virtual NIC. As I also understand the VMnet8 is used to connect the Internet:
Ethernet adapter VMware Network Adapter VMnet8:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet8
Physical Address. . . . . . . . . : 00-50-56-C0-00-08
Dhcp Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : 192.168.214.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
Ethernet adapter VMware Network Adapter VMnet1:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet1
Physical Address. . . . . . . . . : 00-50-56-C0-00-01
Dhcp Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : 192.168.87.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
Then I downloaded VMX Builder to create virtual machines which will be my guests to the host machine. For this example I used BackTrack to install it as a virtual machine and did the following steps below so that it can have access to my other physical machines in the LAN and the Internet:
slax ~ # ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:93:BB:00
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:18 Base address:0x1080
lo Link encap:Local Loopback
inet addr: 127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
sit0 Link encap:UNSPEC HWaddr 00-00-00-00-31-00-00-00-00-00-00-00-00-00-00-00
NOARP MTU:1480 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 ( 0.0 b) TX bytes:0 (0.0 b)
Notice that my guest OS has no IP address. I statically assigned an IP address of (192.168.214.3). Remember that VMnet8 in my host machine has IP (192.168.214.1) since this virtual NIC is used to access the Internet I assigned an IP within that subnet to my guest OS. I did not use IP (192.168.214.2) because VMware use this as a virtual gateway:
slax ~ # ifconfig eth0 192.168.214.3
slax ~ # clear
slax ~ # ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:93:BB:00
inet addr: 192.168.214.3 Bcast:192.168.214.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe93:bb00/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:308 (308.0 b)
Interrupt:18 Base address:0x1080
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask: 255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Let's check the routing table for this guest machine:
slax ~ # netstat -nr
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.214.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
Looking at the routing table I can see that I can send packets to (192.168.214.0) subnet via the eth0 interface. If I create additional virtual machines and statically assigned IP address within this subnet then my packets will reach them. However, I see there's no way for my packets to reach the Internet. Need to add an entry to the routing table:
slax ~ # route add default gw 192.168.214.2 eth0
slax ~ # clear
slax ~ # netstat -nr
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.214.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 192.168.214.2 0.0.0.0 UG 0 0 0 eth0
I added a default gateway which is (192.168.214.2) the virtual VMware gateway. Now any packets destined to (0.0.0.0-what ever IP) but not 192.168.214.0/24 and 127.0.0.0/8 will be routed to (192.168.214.2) gateway via eth0 then from there to my host machine which will NAT (my VMware is set to NAT) the source IP with the IP of my host machine. If the packet is intended for the Internet then this packet will be routed to my SOHO router and off it goes.
Lets test by pinging my router:
slax ~ # ping 192.168.1.33
PING 192.168.1.33 (192.168.1.33) 56(84) bytes of data.
64 bytes from 192.168.1.33: icmp_seq=1 ttl=128 time=15.4 ms
64 bytes from 192.168.1.33: icmp_seq=2 ttl=128 time=6.93 ms
64 bytes from 192.168.1.33: icmp_seq=3 ttl=128 time= 4.25 ms
Awesome it works : )
Now when I fired up my browser to request this site's page, I was receiving connection errors. I used tcpdump to see what was happening and noticed that my guest OS was trying to resolve the domain name to IP using an non-existing DNS server so I configured the resolv.conf to add my DNS server IP (10.0.0.138). I got this IP from my host (Windows) configuration:
slax ~ # cat /etc/resolv.conf
nameserver 10.0.0.138
And boom it worked. Now I can access to the Internet from my virtual OS.
I hope this helps.