0

The goal is to set a static ip for a wifi device on a machine called myhost, which is running Ubuntu 18.04 LTS. The device name is wlp1s0, and the desired ip address is 192.168.1.10. All attempts have failed.

Sequence of steps:

1) Identify ip:

$ ip route
default via 192.168.1.254 dev wlp1s0 proto dhcp metric 600 
169.254.0.0/16 dev wlp1s0 scope link metric 1000 
192.168.1.0/24 dev wlp1s0 proto kernel scope link src 192.168.1.154 metric 600 

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.254   0.0.0.0         UG    600    0        0 wlp1s0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wlp1s0
192.168.1.0     0.0.0.0         255.255.255.0   U     600    0        0 wlp1s0

2) Examine /etc/resolv.conf

$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.1
search attlocal.net

3) Bring down the device

sudo ip link set down

4) Edit /etc/network/interfaces

Edited version:

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

auto wlp1s0
iface wlp1s0 inet static
    address 192.168.1.10
    netmask 255.255.255.0
    gateway 192.168.1.254

5) Edit /etc/hosts

Edited version:

cat /etc/hosts
127.0.0.1   localhost
192.168.1.10     myhost

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::6 ip6-allnodes
ff02::2 ip6-allrouters
192.168.1.180 mysystem.mydomain

6) Bring device back up:

sudo ip link set wlp1s0 up

7) Reboot machine

reboot

After reboot

$ ip route
default via 192.168.1.254 dev wlp1s0 onlink linkdown 
169.254.0.0/16 dev wlp1s0 scope link metric 1000 linkdown 
192.168.1.0/24 dev wlp1s0 proto kernel scope link src 192.168.1.10 linkdown

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.254   0.0.0.0         UG    0      0        0 wlp1s0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wlp1s0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 wlp1s0

$ dmesg | grep wlp1s0
[   37.095682] iwlwifi 0000:01:00.0 wlp1s0: renamed from wlan0
[   38.911441] IPv6: ADDRCONF(NETDEV_UP): wlp1s0: link is not ready

Attempted to add nameservers to /etc/network/interfaces:

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

auto wlp1s0
iface wlp1s0 inet static
    address 192.168.1.10
    netmask 255.255.255.0
    gateway 192.168.1.254
    dns-nameservers 192.168.1.254

That did not work.

What's missing here?

5
  • What does ip address say? Dec 27, 2018 at 8:08
  • Network Manager is designed to interfere with setting static-IP (and makes the advice which you used obsolete). The easy way is to use the desktop configuration to tell Network Manager to make a static IP. Some nuances (such as DNS search-list) were eventually added to the GUI after several years (if your GUI doesn't show that, you'd have to edit the text file that Network Manager maintains). Dec 27, 2018 at 9:25
  • And what do you do if you don't have(and don't want) a desktop on the machine? Dec 27, 2018 at 9:36
  • 1
    Doesn't 18.04 use netplan? see for example How to setup a static IP on Ubuntu 18.04 - server Dec 27, 2018 at 11:27
  • See this guide: Setup network on Ubuntu 18.04
    – rasho
    Jan 16, 2019 at 7:20

1 Answer 1

0

For Ubuntu 18.04 as mentioned above, Netplan seems to be the way forward.

There are multiple useful resources on: https://netplan.io/examples/ and especially for your particular case the following configuration might do the trick:

network:
version: 2
   wifis:
    wlp1s0:
        dhcp4: no
        addresses: 192.168.1.10
        gateway4: 192.168.1.254
        nameservers:
            addresses: [8.8.8.8]
        access-points:
            "network_ssid_name":
                password: "**********"

Take note that indentation is very important, and if not done correctly, the configuration will not work.

After the above configuration is added to the yaml file found in /etc/netplan proceed to run sudo netplan --debug apply.

This command will provide information about what went wrong, otherwise it will restart your network.

You must log in to answer this question.