16

This is the output of ifconfig

# ifconfig
enp0s3    Link encap:Ethernet  HWaddr 08:00:27:ef:b6:e6
          inet addr:192.168.2.3  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::cf19:776a:4d5c:36e0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:713069 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6767 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:45869812 (45.8 MB)  TX bytes:667164 (667.1 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:1108 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1108 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:86846 (86.8 KB)  TX bytes:86846 (86.8 KB)

When I do

# ifdown enp0s3

It says Unknown interface enp0s3

The network is fine and works without any issues. Its just the command that does not work

Ubuntu 16.04 (Xenial)

Below is the output of ip a s

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
   valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:ef:b6:e6 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.7/24 brd 192.168.2.255 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::cf19:776a:4d5c:36e0/64 scope link
       valid_lft forever preferred_lft forever

Below is my /etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

Output of nmcli conn sh

Wired connection 1  42d740b1-21c3-3b7c-8b9e-5922fe8a6380  802-3-ethernet  enp0s3
searcot jabali
  • 261
  • 1
  • 2
  • 6
  • 7
    Have you tried `ip link set dev enp0s3 up` Does `enp0s3` match your configuration in `/etc/network/interfaces` ? – Valentin Bajrami Oct 30 '17 at 08:56
  • What is the output of ip a s ? – bgtvfr Oct 30 '17 at 08:57
  • @bgtvfr : The output is too long to paste in one go. So Multi comment `1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever` – searcot jabali Oct 30 '17 at 10:39
  • @bgtvfr: Part 2 of output `2: enp0s3: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 08:00:27:ef:b6:e6 brd ff:ff:ff:ff:ff:ff inet 192.168.2.7/24 brd 192.168.2.255 scope global enp0s3 valid_lft forever preferred_lft forever inet6 fe80::cf19:776a:4d5c:36e0/64 scope link valid_lft forever preferred_lft forever` – searcot jabali Oct 30 '17 at 10:39
  • @val0x00ff: Weirdly my interfaces file has only this in it `# interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback ` – searcot jabali Oct 30 '17 at 10:40
  • @searcotjabali please update your question with these additional details. Comments read very hard! Your network is controlled by `NetworkManager` and you can use `nmcli conn sh` to see the connections. Also `ifconfig` is obsoleted by `ip` which is a command from `iproute2` tools. Use `ip` instead as I stated in my first comment – Valentin Bajrami Oct 30 '17 at 10:44
  • @val0x00ff: Sorry. I am kinda used to ifconfig. I updated my question with the details. Thanks :-) – searcot jabali Oct 30 '17 at 10:52
  • @searcotjabali please see `man nmcli` how to control your interfaces. You are using `NetworkManager` which controls your interfaces. The man page has many examples that show you how to bring an interface up or down. – Valentin Bajrami Oct 30 '17 at 10:57

2 Answers2

23

ifup and ifdown are used to set up interfaces listed in /etc/network/interfaces . enp0s3 isn't described in this file, so it's absolutely expected that ifup and ifdown don't know what to do with it. Add some lines such as

iface enp0s3 inet dhcp

And you'll see that it will work much better.

wazoox
  • 6,782
  • 4
  • 30
  • 62
  • Sorry, can you explain what's done here? Are you just defining the interface enp0s3 as an internet+dhcp interface? – Hellreaver Jun 08 '21 at 10:46
  • 1
    @Hellreaver Yes. Notice that the interface must already exist in the "ip" or "ifconfig" output. For the detailed syntax of /etc/network/interfaces please Read The Fine Manual: "man interfaces" or see http://manpages.org/etc-network-interfaces/5 – wazoox Jun 09 '21 at 11:11
4

I used the following commands:

cat /proc/net/dev
ls /sys/class/net
ip link show
ifconfig

sudo ifconfig [interface-name] down / up
Patrick Mevzek
  • 9,273
  • 7
  • 29
  • 42
Saman Sam
  • 41
  • 2