I have installed Ubuntu Server 10.04 as a guest operating system under VirtualBox 3.2.10. My host system is Ubuntu 9.04

I have configured two network adapters for the guess (a NAT one and a host-only one)

The NAT one is recognized without problems by the guest, but in order to recognize the host-only adapter I have to run sudo dhclient, thus making it impossible to run the guest in headless mode.

I'm sure I am forgetting something.

When i run ifconfig right after login I see two interfaces (eth0 and lo), then after running sudo dhclient I see three interfaces (eth0, eth1 and lo)

So the question is: How can I make ubuntu to get the IP from the second adapter at boot time in order to be capable of running headless and accessing it via ssh?

  • Sorry, but I've got to ask: Did you run ifconfig or ifconfig -a ?? – Jeremy Oct 17 '10 at 7:10
  • @Jeremy: ifconfig but then i see your question and ran ifconfig -a. But the output of both commands is (at least for me) exactly the same. Anyway it appears to be a bug in VirtualBox DHCP server implementation. – Cesar Oct 17 '10 at 7:17
  • Kk, I can't really help you, just wanted to check if the interface was present, but down. Good luck! You could try Oracle <shudder> (Sun) support, if it's a bug in VBox, they'll be all over it. – Jeremy Oct 17 '10 at 8:57
  • your comment on the dhclient saved me, i was wondering why i cant get adapter 2 to work in any situation. this now has it enrolled, thanks. I have a RHEL so not able to follow @cvrse suggestions. – Brian Thomas Aug 17 '17 at 22:13

have you got the interface configured in /etc/network/interfaces ? if not add the lines

 auto eth1
 iface eth1 inet dhcp

and restart

| improve this answer | |
  • 2
    If you would like to avoid the system restart, you can use "sudo service networking restart" instead. – ssamuel Aug 29 '12 at 15:11
  • 1
    To figure out what interfaces are available, use ip link. It'll show you the interfaces you have. You can then run the commands above, replacing eth1 with what you saw in the previous command – Highmastdon Jan 26 '17 at 17:53
  • 1
    @Highmastdon - thanks! That was the missing link for me. systemd went from ens3 (the only network adapter aside from lo) - to ens9, and I was trying this^ answer with ens4. Super helpful, thanks! – rm-vanda Oct 2 '17 at 18:50

To find your available interfaces use:

ip link

this will show you the interfaces you have, like so:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:1d:bd:93 brd ff:ff:ff:ff:ff:ff
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:c2:c1:92 brd ff:ff:ff:ff:ff:ff

Now add the last interface to the interfaces (in this case enp0s8)

vi /etc/network/interfaces

Type in [i] to edit (and move with arrow keys or before [i] hjkl (left, down, up, right))

auto enp0s8
iface enp0s8 inet dhcp

Save and close with [esc] :wq

| improve this answer | |
  • 1
    or just use nano instead of vi! :D – Riki137 Apr 24 '17 at 16:27

For latest versions (18.04) of the Ubuntu, network settings are stored in /etc/netplan/50-cloud-init.yaml.

  1. Get device name with dmesg | grep enp (enp could be replaced to your device type).

  2. Then insert (for device named enp0s8):

      addresses: []
      dhcp4: true
      optional: true
  3. Then use sudo netplan apply to apply changes.

| improve this answer | |
  • This one solves the issue with ubuntu 18.04 VM. – Pandurang Patil Dec 16 '19 at 9:04
  • Worked for me too. Thanks – enrico69 Feb 8 at 14:15
vi /etc/network/interfaces

press i and add the text

auto eth1
iface eth1 inet dhcp

press esc and type :wq and enter

Then do:

/etc/init.d/networking restart
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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