How to set a static ip on Ubuntu 18.04 LTS












0















This was asked here for Debian Wheezy, but 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|improve this question

























  • What does ip address say?

    – Johan Myréen
    Dec 27 '18 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).

    – Thomas Dickey
    Dec 27 '18 at 9:25













  • And what do you do if you don't have(and don't want) a desktop on the machine?

    – Henrik
    Dec 27 '18 at 9:36











  • Doesn't 18.04 use netplan? see for example How to setup a static IP on Ubuntu 18.04 - server

    – steeldriver
    Dec 27 '18 at 11:27
















0















This was asked here for Debian Wheezy, but 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|improve this question

























  • What does ip address say?

    – Johan Myréen
    Dec 27 '18 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).

    – Thomas Dickey
    Dec 27 '18 at 9:25













  • And what do you do if you don't have(and don't want) a desktop on the machine?

    – Henrik
    Dec 27 '18 at 9:36











  • Doesn't 18.04 use netplan? see for example How to setup a static IP on Ubuntu 18.04 - server

    – steeldriver
    Dec 27 '18 at 11:27














0












0








0








This was asked here for Debian Wheezy, but 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|improve this question
















This was asked here for Debian Wheezy, but 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|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 27 '18 at 4:58







justinnoor.io

















asked Dec 27 '18 at 4:39









justinnoor.iojustinnoor.io

360218




360218













  • What does ip address say?

    – Johan Myréen
    Dec 27 '18 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).

    – Thomas Dickey
    Dec 27 '18 at 9:25













  • And what do you do if you don't have(and don't want) a desktop on the machine?

    – Henrik
    Dec 27 '18 at 9:36











  • Doesn't 18.04 use netplan? see for example How to setup a static IP on Ubuntu 18.04 - server

    – steeldriver
    Dec 27 '18 at 11:27



















  • What does ip address say?

    – Johan Myréen
    Dec 27 '18 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).

    – Thomas Dickey
    Dec 27 '18 at 9:25













  • And what do you do if you don't have(and don't want) a desktop on the machine?

    – Henrik
    Dec 27 '18 at 9:36











  • Doesn't 18.04 use netplan? see for example How to setup a static IP on Ubuntu 18.04 - server

    – steeldriver
    Dec 27 '18 at 11:27

















What does ip address say?

– Johan Myréen
Dec 27 '18 at 8:08





What does ip address say?

– Johan Myréen
Dec 27 '18 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).

– Thomas Dickey
Dec 27 '18 at 9:25







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).

– Thomas Dickey
Dec 27 '18 at 9:25















And what do you do if you don't have(and don't want) a desktop on the machine?

– Henrik
Dec 27 '18 at 9:36





And what do you do if you don't have(and don't want) a desktop on the machine?

– Henrik
Dec 27 '18 at 9:36













Doesn't 18.04 use netplan? see for example How to setup a static IP on Ubuntu 18.04 - server

– steeldriver
Dec 27 '18 at 11:27





Doesn't 18.04 use netplan? see for example How to setup a static IP on Ubuntu 18.04 - server

– steeldriver
Dec 27 '18 at 11:27










1 Answer
1






active

oldest

votes


















0














See this guide: Setup network on Ubuntu 18.04






share|improve this answer








New contributor




rasho is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















    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

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    See this guide: Setup network on Ubuntu 18.04






    share|improve this answer








    New contributor




    rasho is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.

























      0














      See this guide: Setup network on Ubuntu 18.04






      share|improve this answer








      New contributor




      rasho is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.























        0












        0








        0







        See this guide: Setup network on Ubuntu 18.04






        share|improve this answer








        New contributor




        rasho is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.










        See this guide: Setup network on Ubuntu 18.04







        share|improve this answer








        New contributor




        rasho is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        rasho is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 10 mins ago









        rashorasho

        101




        101




        New contributor




        rasho is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        rasho is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        rasho is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






























            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.




            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

            CARDNET

            Boot-repair Failure: Unable to locate package grub-common:i386

            濃尾地震