Enable or add a network interface in Ubuntu Server.

Published on Jul 20 2017

Run all the following commands from a terminal or CLI.

Find the name of the network device:

dmesg | grep -i network

You could also search for "eth" instead of "network"

dmesg | grep -i eth

In my case the interface has been renamed:

[ 1.715063] forcedeth 0000:00:07.0 enp0s7: renamed from eth0 ]

Configure the new or renamed interface with Nano:

sudo nano /etc/network/interfaces 

Add the following lines replacing the interface name with your own.

auto enp0s7
iface enp0s7 inet dhcp

Restart networking:

sudo services networking restart

For a static IP, configure /etc/network/interfaces .

auto enp0s7
iface enp0s7 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255

Info about network interface

From a terminal or CLI run:

ifconfig

example output from ifconfig


enp0s7    Link encap:Ethernet  HWaddr 44:87:fc:59:91:c9
          inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::4687:fcff:fe59:91c9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:116493 errors:0 dropped:0 overruns:0 frame:0
          TX packets:123567 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:58244160 (58.2 MB)  TX bytes:139294642 (139.2 MB)

further Info:

  • dmesg prints the contents of the ring buffer. This information is also sent in real time to syslogd or klogd, when they are running, and ends up in /var/log/messages
  • grep is a command-line utility for searching plain-text data sets for lines that match a regular expression

Updated by db Jul 20 2017 , filed under Linux