Problems using NAT adapter

This is for discussing general topics about how to use VirtualBox.
Post Reply
sim085
Posts: 26
Joined: 6. Jul 2007, 13:46

Problems using NAT adapter

Post by sim085 »

Hello, I have been having some problems with the NAT adapter using Virtual Box with Windows7 as hostOS and Ubuntu 10.04 as guest OS. I have the network adapter set equal to NAT. After installation, in the /etc/network/interfaces file, I have iface eth0 inet dhcp. This from what I understand means that the IP is going to be dynamic, i.e. - given to the machine. In this case, since the adapter type is NAT, then isn't VirtualBox responsible to give an IP to this machine? For some reason eth0 is never coming up (ifconfig does not show it) and I need to resolve using a command such as sudo dhclient in order to get a connection listed. This seems to give an IP to my machine. However my question is, why do I need to run this command on startup each time??

NOTE: When I do the command dhclient the device that comes up in ifconfig is not eth0 but eth2!!

Also, if I am using NAT adapter, then does it mean that all requests from the virtual machine (in this case Linux) will appear as if coming from my hostOS to the network to which the latter is connected?
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Problems using NAT adapter

Post by Perryg »

You have changed the MAC address at some point more than likely and eth0 is the one that the guest saves for automatic network. To get this back you can either edit the /etc/udev/rules.d/70-persistent-net.rules or you can delete the rules and Linux will configure it on the next boot
sim085
Posts: 26
Joined: 6. Jul 2007, 13:46

Re: Problems using NAT adapter

Post by sim085 »

Perryg wrote:You have changed the MAC address at some point more than likely and eth0 is the one that the guest saves for automatic network. To get this back you can either edit the /etc/udev/rules.d/70-persistent-net.rules or you can delete the rules and Linux will configure it on the next boot
Thanks - that's what it is :) I have been using the same vm on different instances of virtual box which obviously meant that I had different mac addresses. Thanks again for the help. You solved my problem and I learnt something new both on VirtualBox and Linux :)

Regards,
Simon J.
Post Reply