Failed to bring up eth2 - Ubuntu 16.04

I set up an Ubuntu 16.04 server as guest in Virtualbox. The server uses 3 interfaces in the network settings: Host-only, NAT, Bridged

The /etc/network/interfaces file is set as following:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# Host-only interface
auto eth0
iface eth0 inet static
address 192.168.56.105
netmask 255.255.255.0
network 192.168.56.0
broadcast 192.168.56.255

# NAT interface
auto eth1
iface eth1 inet dhcp

# Bridged interface
auto eth2
iface eth2 inet static
address 192.168.0.105
netmask 255.255.255.0
gateway 192.168.0.255
dns-nameservers 8.8.8.8

I've disabled the "Predictable Network Interface Names" option into the grub config

GRUB_CMDLINE_LINUX_DEFAULT="net.ifnames=0"

During the reboot I have this message:

Failed to start Raise network interfaces

but when I run ifconfig everything seems ok:

eth0      Link encap:Ethernet  HWaddr 08:00:27:37:e4:c4  
          inet addr:192.168.56.105  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe37:e4c4/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:311 errors:0 dropped:0 overruns:0 frame:0
          TX packets:39 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:35338 (35.3 KB)  TX bytes:5530 (5.5 KB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:d6:8d:1a  
          inet addr:10.0.3.15  Bcast:10.0.3.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fed6:8d1a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:29 errors:0 dropped:0 overruns:0 frame:0
          TX packets:37 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2970 (2.9 KB)  TX bytes:3063 (3.0 KB)

eth2      Link encap:Ethernet  HWaddr 08:00:27:6d:be:ad  
          inet addr:192.168.0.105  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe6d:bead/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:634 errors:0 dropped:0 overruns:0 frame:0
          TX packets:29 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:55125 (55.1 KB)  TX bytes:1988 (1.9 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:160 errors:0 dropped:0 overruns:0 frame:0
          TX packets:160 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:11840 (11.8 KB)  TX bytes:11840 (11.8 KB)

However when I run

sudo service networking restart

I get this message:

Job for networking.service failed because the control process exited with 
error code. See "systemctl status networking.service" and "journalctl -xe" 
for details.

Here's the result of journalctl -xe

-- Unit networking.service has begun starting up.
May 07 16:31:54 jakku ifup[2056]: RTNETLINK answers: File exists
May 07 16:31:54 jakku ifup[2056]: Failed to bring up eth2.
May 07 16:31:54 jakku systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
May 07 16:31:54 jakku systemd[1]: Failed to start Raise network interfaces.
-- Subject: Unit networking.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit networking.service has failed.

Can someone help me?


Solution 1:

My guess is that you are falling into an old trap. According to several posts e.g. one by codeghar sudo service networking restart has long been deprecated

because it may not enable again some interfaces

Jorge Castro gave this answer

sudo ifdown --exclude=lo -a && sudo ifup --exclude=lo -a

So replace networking restart with ifdown... && ifup....

Just as an aside: ifconfig has also been deprecated for a long time - use ip from the package iproute2 (also see my question/answer)