Why is the network configuration I set in /etc/network/interfaces ignored on Ubuntu 17.10?

6,251

Solution 1

Networking is handled by netplan by default in Ubuntu Server 17.10 and later. I suggest that you edit the /etc/netplan/01-netcfg.yaml file to read:

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  wifis:
    wlp2s0b1:
      dhcp4: no
      dhcp6: no
      addresses: [192.168.0.21/24]
      gateway4: 192.168.0.1
      nameservers:
        addresses: [8.8.8.8,192.168.0.1]
      access-points: 
        "******":
          password: "**********"

Exit and save your changes by running the command:

sudo netplan generate
sudo netplan apply

Please note and follow the spacing and indentation. Also note that the SSID and password are in between quotes ".

Comment out all the wlp2s0b1 stanzas in /etc/network/interfaces and reboot.

Any improvement?

NOTE: The exact method to set a static IP address for a server with netplan and wifi is hard to find. We may need to tweak the settings a bit.

Solution 2

I suggest you to completely remove netplan package and use networkd by creating config(s) in /etc/systemd/network/ directory. Netplan exists only in Ubuntu and there are no one in any other distros.

Share:
6,251
lucius
Author by

lucius

Updated on September 18, 2022

Comments

  • lucius
    lucius over 1 year

    I've just installed ubuntu server 17.10. During installation, it suggested me to connect to the network through wifi, and so i did. After installation was finished and system was rebooted, computer connected to the wifi automatically (which means, it saved the connection creds somewhere). But in /etc/network/interfaces i found nothing. I need my computer connect to wifi network with static ip, so I've put configuration into the /etc/network/interfaces:

    # /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
    # Generated by debian-installer.
    
    # The loopback interface
    auto lo
    iface lo inet loopback
    
    
    iface wlp2s0b1 inet static
            wpa-driver wext
            address 192.168.0.12
            netmask 255.255.255.0
            gateway 192.168.0.1
            wpa-ssid *****
            wpa-psk **********
            dns-nameservers 8.8.8.8 192.168.0.1
    auto wlp2s0b1
    

    When system starts, it doesn't connect using my configuration. It does only after

    sudo ifdown wlp2s0b1 && sudo ifup -v wlp2s0b1

    and after this command, system getting a SECOND IP! Server is still available by the ip it gets from DHCP, and in the same time, it is available by the static ip!

    • chili555
      chili555 over 6 years
      Please edit your question to add the result of: cat /etc/network/interfaces . Welcome to Ask Ubuntu.
    • lucius
      lucius over 6 years
      > Please edit your question to add the result of: cat /etc/network/interfaces. Done! > Welcome to Ask Ubuntu. Thank you!
    • chili555
      chili555 over 6 years
      Please edit out this: wpa-driver wext Next, do: sudo ifdown wlp2s0b1 && sudo ifup -v wlp2s0b1 The -v for verbose should produce some clues as to what's going on or going wrong. Paste it here and give us the link: paste.ubuntu.com
    • lucius
      lucius over 6 years
      Should i remove this line? wpa-driver wext
    • chili555
      chili555 over 6 years
      Yes, please and then: sudo ifdown wlp2s0b1 && sudo ifup -v wlp2s0b1 and then paste the output so we can see what's going wrong. Also, when it gets an IP address, presumably by DHCP, what is the address?
    • lucius
      lucius over 6 years
      paste.ubuntu.com/25963423 As i described in the topic, this command made server to get a second ip. Now server is reachable by static ip 192.169.0.12 and by the ip, which it has from DHCP. The address from DHCP is 192.168.0.21 (it's in range from 192.168.0.20-255 configured on router)
    • chili555
      chili555 over 6 years
      "RTNETLINK answers: Cannot assign requested address" Does some other device on the network have the address? Are you quite sure that the DHCP range is from x.20 to x.255 (actually, it is likely 254 and 255 are reserved.) Do you really expect 200+ guests that need DHCP? Have you tried rebooting the server and the router?
    • lucius
      lucius over 6 years
      IPs are in use: 192.168.0.21 (server), 192.168.0.26, 192.168.0.22, 192.168.0.24, 192.168.0.23, 192.168.0.20. About range: yes, it was below 254, sorry. I've changed the top restriction to 192.168.0.35. I was rebooting server tens times. Now i rebooted my router and then server. Nothing change.
    • chili555
      chili555 over 6 years
      May we see: ps aux | grep -i -e network -e wicd
    • lucius
      lucius over 6 years
    • chili555
      chili555 over 6 years
      !!! May we see: ls /etc/netplan? Possible clue: wiki.ubuntu.com/Netplan
    • lucius
      lucius over 6 years
      YES!!! It is there! What should i do? Just remove the wifis config from the file or entire file?
    • chili555
      chili555 over 6 years
      No, I suggest that we properly configure it and abandon /etc/network/interfaces. I'm reading and will propose an answer in a while. Please paste its name and contents.
    • lucius
      lucius over 6 years
      name: 01-netcfg.yaml; content: paste.ubuntu.com/25963779
  • lucius
    lucius over 6 years
    You spent 2 hours (!) of your life on my problem, and now it is solved! Thank you! I love ubuntu community!
  • chili555
    chili555 over 6 years
    No, thank you! I enjoy challenging problems. Glad it's working.
  • Alexey Ce
    Alexey Ce over 6 years
    netplan is just for server network admin?
  • chili555
    chili555 over 6 years
    @Thufir netplan is also used in destop installations but, by default, turns over configuration to Network Manager.
  • Nabheet
    Nabheet about 6 years
    This is awesome! However, I needed to install wpasupplicant on my ubuntu server too.
  • chili555
    chili555 about 6 years
    @Fabby I believe quotes are " and double-quotes are "" which is incorrect.
  • Fabby
    Fabby about 6 years
    Oh, I thought single quotes were ' and double quotes were ". Removing... Sorry for having caused you grief! ;-)
  • kol
    kol almost 6 years
    sudo netplan generate should be run before sudo netplan apply, see askubuntu.com/a/883378/164374
  • kol
    kol almost 6 years
    You also need to have wpasupplicant installed, or networkctl will say no-carrier.
  • karel
    karel over 5 years
    The netplan.io package does not exist in the default 17.10 repositories.
  • Gannet
    Gannet over 5 years
    Sorry, it is in 18.04. If you want to move to networkd, you just neet to: 1) sudo systemctl enable systemd-networkd 2) sudo rm /etc/network/interfaces 3) sudo rm /etc/netplan/*