23

I've just installed the latest Ubuntu 16.04 on a VirtualBox machine. I'd like to have two different network interfaces:

  1. the first one to access the guest machine from the host using ssh; for this reason, I've installed the Host-only Adapter as adapter 1
  2. the second one to be able to connect to internet from the host machine, so I've installed a basic NAT as adapter 2

However, even if both the network adapters are correctly identified, only the first one is accessible.

$ ls /sys/class/net/
enp0s3  enp0s8  lo

$ ifconfig
enp0s3    Link encap:Ethernet  HWaddr 08:00:27:47:52:7b  
          inet addr:192.168.56.101  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe47:527b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:399 errors:0 dropped:0 overruns:0 frame:0
          TX packets:246 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:44031 (44.0 KB)  TX bytes:75269 (75.2 KB)

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:65536  Metric:1
          RX packets:92 errors:0 dropped:0 overruns:0 frame:0
          TX packets:92 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:40721 (40.7 KB)  TX bytes:40721 (40.7 KB)

How can I make the system recognize the second card also?

2 Answers 2

21

I've solved the problem adding

# The secondary network interface
auto enp0s8
iface enp0s8 inet dhcp

to /etc/network/interfaces

(Get the new interface name using ifconfig -a)

and restarting the network using sudo service networking restart.

Now, here is the result of

$ ifconfig enp0s3    Link encap:Ethernet  HWaddr 08:00:27:47:52:7b  
          inet addr:192.168.56.101  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe47:527b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6334 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7656 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2741526 (2.7 MB)  TX bytes:10824219 (10.8 MB)

enp0s8    Link encap:Ethernet  HWaddr 08:00:27:3e:1e:bf  
          inet addr:10.0.3.15  Bcast:10.0.3.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe3e:1ebf/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1730 (1.7 KB)  TX bytes:1882 (1.8 KB)

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:65536  Metric:1
          RX packets:2143 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2143 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:443165 (443.1 KB)  TX bytes:443165 (443.1 KB)
5
  • How did you find the network interface's name? Jun 23, 2017 at 8:25
  • 5
    @GeorgSchölly I think you can easily list them with ifconfig or ifconfig -a. Is that what you mean?
    – tigerjack
    Jun 24, 2017 at 6:13
  • That's exactly it. I was not aware of the -a argument. Thank you. Jun 24, 2017 at 8:27
  • 2
    You don't need to restart all of networking. If you just run ifup enp0s8, the system scripts will bring up the interface without restarting everything else. If you already have working networking and just need to add an additional interface, this should be all you need.
    – David C.
    Mar 19, 2018 at 15:39
  • Replaced by netplan. Do not use this method. Bad info now. ifconfig should not be used anymore either.
    – B. Shea
    Dec 7, 2021 at 15:56
17

The new versions of Ubuntu Server use netplan instead of ifup.

You have to edit /etc/netplan/00-installer-config.yaml:

network:
  ethernets:
     enp0s3:
        dhcp4: true
     enp0s8:
        dhcp4: true
version: 2

And then run:

netplan apply

Then it should pop up!

3
  • 2
    Thanks, this is just what I needed on 20.04 :)
    – antsyawn
    Jun 25, 2020 at 11:38
  • 3
    Did you read the top of the file /etc/netplan/50-cloud-init.yaml ? : This file is generated from information provided by the datasource. Changes to it will not persist across an instance. TRY HERE: ubuntu.com/server/docs/network-configuration - You will probably need to create your own netplan instead.
    – B. Shea
    Dec 7, 2021 at 15:53
  • In Ubuntu Server 22.04 the file is /etc/netplan/00-installer-config.yaml.
    – sotirov
    Oct 12 at 17:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .