1

I've just installed Ubuntu for the first time and I want to set up a fixed IP address for my computer as a first step towards connecting from outside via ssh. I can find no menu in my router to associate an IP address to a MAC address, so instead I have gone to /etc/netplan where I see a file named 01-network-manager-all.yaml which contains:

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager

I append it to contain:

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager
  wifis:
    wlp5s0:
      addresses: [192.168.0.100/24]
      dhcp4: no
      gateway4: 192.168.0.1
      access-points:
        sparrow:
          password: my password

Next I run:

ian@sparrow:~$ sudo netplan --debug apply
** (generate:2459): DEBUG: 08:03:58.881: Processing input file //etc/netplan/01-network-manager-all.yaml..
** (generate:2459): DEBUG: 08:03:58.881: starting new processing pass
** (generate:2459): DEBUG: 08:03:58.881: wlp5s0: adding wifi AP 'sparrow'
** (generate:2459): DEBUG: 08:03:58.881: wlp5s0: setting default backend to 2
** (generate:2459): DEBUG: 08:03:58.882: Generating output files..
** (generate:2459): DEBUG: 08:03:58.882: networkd: definition wlp5s0 is not for us (backend 2)
DEBUG:no netplan generated networkd configuration exists
DEBUG:netplan generated NM configuration exists, restarting NM
DEBUG:replug enp4s0: unbinding 0000:04:00.0 from /sys/bus/pci/drivers/r8169
DEBUG:replug enp4s0: rebinding 0000:04:00.0 to /sys/bus/pci/drivers/r8169
DEBUG:replug wlp5s0: unbinding 0000:05:00.0 from /sys/bus/pci/drivers/iwlwifi
DEBUG:replug wlp5s0: rebinding 0000:05:00.0 to /sys/bus/pci/drivers/iwlwifi
DEBUG:device lo operstate is unknown, not replugging
DEBUG:netplan triggering .link rules for lo
ian@sparrow:~$

I am not sure what to make of this output.

To see what's going on, I reboot things and run:

ian@sparrow:/etc/netplan$ ip a
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: enp4s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether b0:6e:bf:0a:9a:5d brd ff:ff:ff:ff:ff:ff
3: wlp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:e1:8c:7f:10:48 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.102/24 brd 192.168.0.255 scope global dynamic noprefixroute wlp5s0
       valid_lft 86003sec preferred_lft 86003sec
    inet6 fe80::1d31:c36:616f:422c/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
ian@sparrow:/etc/netplan$ 

Which indicates that my attempt to get Ubuntu to ask for 192.168.0.100/24 has failed.
How do I fix my machine's LAN IP?

After generating 01-networkd.yaml as described below, I run ip a and I get:

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: enp4s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether b0:6e:bf:0a:9a:5d brd ff:ff:ff:ff:ff:ff
3: wlp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
      link/ether 00:e1:8c:7f:10:48 brd ff:ff:ff:ff:ff:ff
      inet 192.168.0.102/24 brd 192.168.0.255 scope global dynamic noprefixroute wlp5s0
         valid_lft 86003sec preferred_lft 86003sec
      inet6 fe80::1d31:c36:616f:422c/64 scope link noprefixroute 
         valid_lft forever preferred_lft forever
ian@sparrow:/etc/netplan$ 

Correction: output from sudo netplan --debug generate is:

Processing input file //etc/netplan/01-networkd.yaml..
starting new processing pass
wlp5s0: adding wifi AP 'sparrow
enp4s0: setting default backend to 1
wlp5s0: setting default backend to 1
Generating output files..
NetworkManager: definition enp4s0 is not for us (backend 1)
wlp5s0: Creating wpa_supplicant configuration file run/netplan/wpa-wlp5s0.conf
Creating wpa_supplicant service enablement link /run/systemd/system/multi-user.target.wants/[email protected]
NetworkManager: definition wlp5s0 is not for us (backend 1)
5
  • Why not simply set the addresses in Network Manager? Welcome to Ask Ubuntu.
    – chili555
    Oct 11, 2018 at 0:47
  • I have no network manager. I gave up trying to guess where that functionality had been moved to in 18.04 and went for the command line alternative. Have just realised that sudo apt-get install network-manager is my friend. Oct 12, 2018 at 10:17
  • Then "renderer: NetworkManager" is incorrect.
    – chili555
    Oct 14, 2018 at 0:35
  • Clarification. When I said I have no Network Manager, I was referring to the absence of the "network" icon in the top-right section of the screen. Saying "sudo apt-get install network-manager" generates output indicating that it is already installed and up to date. Accessing the GUI is the problem. I have found that either "sudo nm-connection-editor" or clicking the "wireless" icon in the top-right and then wi-fi settings and then the pressing the button on that network, will get me to the IPv4 menu area described in heynnema's screenshot below. Oct 14, 2018 at 21:09
  • If you have NM installed and running, then that is where to make your change. I suggest that you revert the additions to netplan.
    – chili555
    Oct 14, 2018 at 21:14

1 Answer 1

2

If you must use Netplan...

remove /etc/netplan/01-network-manager-all.yaml

create /etc/netplan/01-networkd.yaml...

network:
  version: 2
  renderer: networkd
  ethernets:
    enp4s0:
      dhcp4: true
      optional: true
  wifis:
    wlp5s0:
      addresses: [192.168.0.100/24]
      gateway4: 192.168.0.1
      nameservers:
        addresses: [192.168.0.1, 8.8.8.8]
      access-points:
        "sparrow":
          password: "**********"

sudo netplan --debug generate

sudo netplan apply

reboot

If you decide to stick with NetworkManager...

remove all unnecessary .yaml files in /etc/netplan

create /etc/netplan/01-network-manager-all.yaml...

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager

sudo netplan --debug generate

sudo netplan apply

reboot

Connect to the desired wireless network.

Disconnect from the wireless network.

Edit these settings in the (18.04.1) wireless profile...

enter image description here

Update #1:

  • added code for enp4s0 LAN connection
  • added reboot
  • added info about using NetworkManager
15
  • 1
    Tried this and lost contact with the LAN altogether. Oct 12, 2018 at 10:18
  • Did the WLAN or LAN lose contact? You didn't say that you were using LAN. If you are using LAN, then my example code is not complete, and you would loose LAN connection. Did you reboot?
    – heynnema
    Oct 12, 2018 at 12:26
  • I have found my way to the IPV4 menu via both nm-connection-editor and via GUI and entered network descriptions with and without various DNS alternatives (having reverted to the original 01-network-manager-all.yaml). Upon reboot the computer is in a state where the "wireless" icon is replaced with a question mark. My dropbox is greyed out and Firefox can't connect to the internet. Clicking the ? icon gets to the usual wireless menus but the system reports that I am already connected (therefore cannot click "connect"). Oct 14, 2018 at 21:21
  • What files are in /etc/netplan? If you have (only) 01-network-manager-all.yaml, does it look like my example? Did you issue the THREE commands that I call out? Have you rebooted?
    – heynnema
    Oct 14, 2018 at 22:02
  • I removed the .yaml.bup and .txt files that I had accumulated in /etc/netplan and created 01-networkd.yaml exactly as described. sudo netplan --debug generate gave no output. sudo netplan apply also gave none. reboot. Wifi icon absent, Wifi settings lists no visible networks. I will attempt to put output from ip a onto this site (not sure how). Oct 15, 2018 at 8:01

You must log in to answer this question.

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