How to set a static ip on Ubuntu 18.04 LTS












0














This was asked here, but for Debian Wheezy, and the respondent answered the question with a question. It was also asked here, but the answer is not working.



The goal here 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?









share



























    0














    This was asked here, but for Debian Wheezy, and the respondent answered the question with a question. It was also asked here, but the answer is not working.



    The goal here 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?









    share

























      0












      0








      0







      This was asked here, but for Debian Wheezy, and the respondent answered the question with a question. It was also asked here, but the answer is not working.



      The goal here 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?









      share













      This was asked here, but for Debian Wheezy, and the respondent answered the question with a question. It was also asked here, but the answer is not working.



      The goal here 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?







      linux ubuntu networking ip





      share












      share










      share



      share










      asked 3 mins ago









      justinnoor.io

      348218




      348218



























          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491072%2fhow-to-set-a-static-ip-on-ubuntu-18-04-lts%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491072%2fhow-to-set-a-static-ip-on-ubuntu-18-04-lts%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Accessing regular linux commands in Huawei's Dopra Linux

          Can't connect RFCOMM socket: Host is down

          Kernel panic - not syncing: Fatal Exception in Interrupt