Ubuntu Server cannot add permanent static route

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
0
down vote

favorite












I'm running Ubuntu Server 16.04.4

After a lot of struggling I managed to configure both ethernet and wireless connections.



The content of /etc/network/interfaces file is this:



source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# Ethernet network interface
allow-hotplug enp9s0
iface enp9s0 inet static
address 192.168.1.150
netmask 255.255.255.0
gateway 192.168.1.1

# Wireless network interface
allow-hotplug wlp5s0b1
iface wlp5s0b1 inet static
address 192.168.1.151
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

up route add default gw 192.168.1.1 dev wlp5s0b1


and in /etc/wpa_supplicant/wpa_supplicant.conf there is the output of:



wpa_passphrase "MY SSID" MY_PASSWORD | sudo tee /etc/wpa_supplicant/wpa_supplicant.conf


which is:



network=
ssid="MY SSID"
#psk="MY_PASSWORD_IN_CLEAR"
psk=LONG_HEX_STRING



Now, ifconfig shows that:



enp9s0 Link encap:Ethernet IndirizzoHW 00:24:54:ad:ac:b4 
indirizzo inet:192.168.1.150 Bcast:192.168.1.255 Maschera:255.255.255.0
indirizzo inet6: fe80::224:54ff:fead:acb4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:435 errors:0 dropped:0 overruns:0 frame:0
TX packets:195 errors:0 dropped:0 overruns:0 carrier:0
collisioni:0 txqueuelen:1000
Byte RX:54426 (54.4 KB) Byte TX:26620 (26.6 KB)
Interrupt:18

lo Link encap:Loopback locale
indirizzo inet:127.0.0.1 Maschera:255.0.0.0
indirizzo inet6: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:14256 errors:0 dropped:0 overruns:0 frame:0
TX packets:14256 errors:0 dropped:0 overruns:0 carrier:0
collisioni:0 txqueuelen:1
Byte RX:1055216 (1.0 MB) Byte TX:1055216 (1.0 MB)

wlp5s0b1 Link encap:Ethernet IndirizzoHW 00:1b:b1:48:12:86
indirizzo inet:192.168.1.151 Bcast:192.168.1.255 Maschera:255.255.255.0
indirizzo inet6: fe80::21b:b1ff:fe48:1286/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:695 errors:0 dropped:0 overruns:0 frame:0
TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
collisioni:0 txqueuelen:1000
Byte RX:125974 (125.9 KB) Byte TX:3316 (3.3 KB)


and the routing table is this:



tommy@ubuntu-server:~$ route -n
Tabella di routing IP del kernel
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 enp9s0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp9s0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlp5s0b1


If I ping with the ethernet cable connected, all works good.

But if I remove the ethernet cable and ping 8.8.8.8 it's not working.



Now my guess is that in the routing table is missing a line like this:



0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlp5s0b1


In fact, if I run:



sudo route add default gw 192.168.1.1 wlp5s0b1


then the routing table is:



tommy@ubuntu-server:~$ route -n
Tabella di routing IP del kernel
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlp5s0b1
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 enp9s0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp9s0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlp5s0b1


and ping 8.8.8.8 without the ethernet cable work just fine.



So my question is this: is there a way of keep permanent the route that I added?



I've already tried to write the command in the last line of the /etc/network/interfaces file, as you can see above, in many different ways:



  • up route add default gw 192.168.1.1

  • up route add default gw 192.168.1.1 wlp5s0b1

  • up route add default gw 192.168.1.1 dev wlp5s0b1

  • as above but with up ip route ...

  • as above but with post-up instead of up

but it's not working.

Am I missing the correct syntax or is there any other solution?

Thanks for your help!







share|improve this question
























    up vote
    0
    down vote

    favorite












    I'm running Ubuntu Server 16.04.4

    After a lot of struggling I managed to configure both ethernet and wireless connections.



    The content of /etc/network/interfaces file is this:



    source /etc/network/interfaces.d/*

    # The loopback network interface
    auto lo
    iface lo inet loopback

    # Ethernet network interface
    allow-hotplug enp9s0
    iface enp9s0 inet static
    address 192.168.1.150
    netmask 255.255.255.0
    gateway 192.168.1.1

    # Wireless network interface
    allow-hotplug wlp5s0b1
    iface wlp5s0b1 inet static
    address 192.168.1.151
    netmask 255.255.255.0
    gateway 192.168.1.1
    dns-nameservers 192.168.1.1
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

    up route add default gw 192.168.1.1 dev wlp5s0b1


    and in /etc/wpa_supplicant/wpa_supplicant.conf there is the output of:



    wpa_passphrase "MY SSID" MY_PASSWORD | sudo tee /etc/wpa_supplicant/wpa_supplicant.conf


    which is:



    network=
    ssid="MY SSID"
    #psk="MY_PASSWORD_IN_CLEAR"
    psk=LONG_HEX_STRING



    Now, ifconfig shows that:



    enp9s0 Link encap:Ethernet IndirizzoHW 00:24:54:ad:ac:b4 
    indirizzo inet:192.168.1.150 Bcast:192.168.1.255 Maschera:255.255.255.0
    indirizzo inet6: fe80::224:54ff:fead:acb4/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:435 errors:0 dropped:0 overruns:0 frame:0
    TX packets:195 errors:0 dropped:0 overruns:0 carrier:0
    collisioni:0 txqueuelen:1000
    Byte RX:54426 (54.4 KB) Byte TX:26620 (26.6 KB)
    Interrupt:18

    lo Link encap:Loopback locale
    indirizzo inet:127.0.0.1 Maschera:255.0.0.0
    indirizzo inet6: ::1/128 Scope:Host
    UP LOOPBACK RUNNING MTU:65536 Metric:1
    RX packets:14256 errors:0 dropped:0 overruns:0 frame:0
    TX packets:14256 errors:0 dropped:0 overruns:0 carrier:0
    collisioni:0 txqueuelen:1
    Byte RX:1055216 (1.0 MB) Byte TX:1055216 (1.0 MB)

    wlp5s0b1 Link encap:Ethernet IndirizzoHW 00:1b:b1:48:12:86
    indirizzo inet:192.168.1.151 Bcast:192.168.1.255 Maschera:255.255.255.0
    indirizzo inet6: fe80::21b:b1ff:fe48:1286/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:695 errors:0 dropped:0 overruns:0 frame:0
    TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
    collisioni:0 txqueuelen:1000
    Byte RX:125974 (125.9 KB) Byte TX:3316 (3.3 KB)


    and the routing table is this:



    tommy@ubuntu-server:~$ route -n
    Tabella di routing IP del kernel
    Destination Gateway Genmask Flags Metric Ref Use Iface
    0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 enp9s0
    192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp9s0
    192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlp5s0b1


    If I ping with the ethernet cable connected, all works good.

    But if I remove the ethernet cable and ping 8.8.8.8 it's not working.



    Now my guess is that in the routing table is missing a line like this:



    0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlp5s0b1


    In fact, if I run:



    sudo route add default gw 192.168.1.1 wlp5s0b1


    then the routing table is:



    tommy@ubuntu-server:~$ route -n
    Tabella di routing IP del kernel
    Destination Gateway Genmask Flags Metric Ref Use Iface
    0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlp5s0b1
    0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 enp9s0
    192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp9s0
    192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlp5s0b1


    and ping 8.8.8.8 without the ethernet cable work just fine.



    So my question is this: is there a way of keep permanent the route that I added?



    I've already tried to write the command in the last line of the /etc/network/interfaces file, as you can see above, in many different ways:



    • up route add default gw 192.168.1.1

    • up route add default gw 192.168.1.1 wlp5s0b1

    • up route add default gw 192.168.1.1 dev wlp5s0b1

    • as above but with up ip route ...

    • as above but with post-up instead of up

    but it's not working.

    Am I missing the correct syntax or is there any other solution?

    Thanks for your help!







    share|improve this question






















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm running Ubuntu Server 16.04.4

      After a lot of struggling I managed to configure both ethernet and wireless connections.



      The content of /etc/network/interfaces file is this:



      source /etc/network/interfaces.d/*

      # The loopback network interface
      auto lo
      iface lo inet loopback

      # Ethernet network interface
      allow-hotplug enp9s0
      iface enp9s0 inet static
      address 192.168.1.150
      netmask 255.255.255.0
      gateway 192.168.1.1

      # Wireless network interface
      allow-hotplug wlp5s0b1
      iface wlp5s0b1 inet static
      address 192.168.1.151
      netmask 255.255.255.0
      gateway 192.168.1.1
      dns-nameservers 192.168.1.1
      wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

      up route add default gw 192.168.1.1 dev wlp5s0b1


      and in /etc/wpa_supplicant/wpa_supplicant.conf there is the output of:



      wpa_passphrase "MY SSID" MY_PASSWORD | sudo tee /etc/wpa_supplicant/wpa_supplicant.conf


      which is:



      network=
      ssid="MY SSID"
      #psk="MY_PASSWORD_IN_CLEAR"
      psk=LONG_HEX_STRING



      Now, ifconfig shows that:



      enp9s0 Link encap:Ethernet IndirizzoHW 00:24:54:ad:ac:b4 
      indirizzo inet:192.168.1.150 Bcast:192.168.1.255 Maschera:255.255.255.0
      indirizzo inet6: fe80::224:54ff:fead:acb4/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
      RX packets:435 errors:0 dropped:0 overruns:0 frame:0
      TX packets:195 errors:0 dropped:0 overruns:0 carrier:0
      collisioni:0 txqueuelen:1000
      Byte RX:54426 (54.4 KB) Byte TX:26620 (26.6 KB)
      Interrupt:18

      lo Link encap:Loopback locale
      indirizzo inet:127.0.0.1 Maschera:255.0.0.0
      indirizzo inet6: ::1/128 Scope:Host
      UP LOOPBACK RUNNING MTU:65536 Metric:1
      RX packets:14256 errors:0 dropped:0 overruns:0 frame:0
      TX packets:14256 errors:0 dropped:0 overruns:0 carrier:0
      collisioni:0 txqueuelen:1
      Byte RX:1055216 (1.0 MB) Byte TX:1055216 (1.0 MB)

      wlp5s0b1 Link encap:Ethernet IndirizzoHW 00:1b:b1:48:12:86
      indirizzo inet:192.168.1.151 Bcast:192.168.1.255 Maschera:255.255.255.0
      indirizzo inet6: fe80::21b:b1ff:fe48:1286/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
      RX packets:695 errors:0 dropped:0 overruns:0 frame:0
      TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
      collisioni:0 txqueuelen:1000
      Byte RX:125974 (125.9 KB) Byte TX:3316 (3.3 KB)


      and the routing table is this:



      tommy@ubuntu-server:~$ route -n
      Tabella di routing IP del kernel
      Destination Gateway Genmask Flags Metric Ref Use Iface
      0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 enp9s0
      192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp9s0
      192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlp5s0b1


      If I ping with the ethernet cable connected, all works good.

      But if I remove the ethernet cable and ping 8.8.8.8 it's not working.



      Now my guess is that in the routing table is missing a line like this:



      0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlp5s0b1


      In fact, if I run:



      sudo route add default gw 192.168.1.1 wlp5s0b1


      then the routing table is:



      tommy@ubuntu-server:~$ route -n
      Tabella di routing IP del kernel
      Destination Gateway Genmask Flags Metric Ref Use Iface
      0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlp5s0b1
      0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 enp9s0
      192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp9s0
      192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlp5s0b1


      and ping 8.8.8.8 without the ethernet cable work just fine.



      So my question is this: is there a way of keep permanent the route that I added?



      I've already tried to write the command in the last line of the /etc/network/interfaces file, as you can see above, in many different ways:



      • up route add default gw 192.168.1.1

      • up route add default gw 192.168.1.1 wlp5s0b1

      • up route add default gw 192.168.1.1 dev wlp5s0b1

      • as above but with up ip route ...

      • as above but with post-up instead of up

      but it's not working.

      Am I missing the correct syntax or is there any other solution?

      Thanks for your help!







      share|improve this question












      I'm running Ubuntu Server 16.04.4

      After a lot of struggling I managed to configure both ethernet and wireless connections.



      The content of /etc/network/interfaces file is this:



      source /etc/network/interfaces.d/*

      # The loopback network interface
      auto lo
      iface lo inet loopback

      # Ethernet network interface
      allow-hotplug enp9s0
      iface enp9s0 inet static
      address 192.168.1.150
      netmask 255.255.255.0
      gateway 192.168.1.1

      # Wireless network interface
      allow-hotplug wlp5s0b1
      iface wlp5s0b1 inet static
      address 192.168.1.151
      netmask 255.255.255.0
      gateway 192.168.1.1
      dns-nameservers 192.168.1.1
      wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

      up route add default gw 192.168.1.1 dev wlp5s0b1


      and in /etc/wpa_supplicant/wpa_supplicant.conf there is the output of:



      wpa_passphrase "MY SSID" MY_PASSWORD | sudo tee /etc/wpa_supplicant/wpa_supplicant.conf


      which is:



      network=
      ssid="MY SSID"
      #psk="MY_PASSWORD_IN_CLEAR"
      psk=LONG_HEX_STRING



      Now, ifconfig shows that:



      enp9s0 Link encap:Ethernet IndirizzoHW 00:24:54:ad:ac:b4 
      indirizzo inet:192.168.1.150 Bcast:192.168.1.255 Maschera:255.255.255.0
      indirizzo inet6: fe80::224:54ff:fead:acb4/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
      RX packets:435 errors:0 dropped:0 overruns:0 frame:0
      TX packets:195 errors:0 dropped:0 overruns:0 carrier:0
      collisioni:0 txqueuelen:1000
      Byte RX:54426 (54.4 KB) Byte TX:26620 (26.6 KB)
      Interrupt:18

      lo Link encap:Loopback locale
      indirizzo inet:127.0.0.1 Maschera:255.0.0.0
      indirizzo inet6: ::1/128 Scope:Host
      UP LOOPBACK RUNNING MTU:65536 Metric:1
      RX packets:14256 errors:0 dropped:0 overruns:0 frame:0
      TX packets:14256 errors:0 dropped:0 overruns:0 carrier:0
      collisioni:0 txqueuelen:1
      Byte RX:1055216 (1.0 MB) Byte TX:1055216 (1.0 MB)

      wlp5s0b1 Link encap:Ethernet IndirizzoHW 00:1b:b1:48:12:86
      indirizzo inet:192.168.1.151 Bcast:192.168.1.255 Maschera:255.255.255.0
      indirizzo inet6: fe80::21b:b1ff:fe48:1286/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
      RX packets:695 errors:0 dropped:0 overruns:0 frame:0
      TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
      collisioni:0 txqueuelen:1000
      Byte RX:125974 (125.9 KB) Byte TX:3316 (3.3 KB)


      and the routing table is this:



      tommy@ubuntu-server:~$ route -n
      Tabella di routing IP del kernel
      Destination Gateway Genmask Flags Metric Ref Use Iface
      0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 enp9s0
      192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp9s0
      192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlp5s0b1


      If I ping with the ethernet cable connected, all works good.

      But if I remove the ethernet cable and ping 8.8.8.8 it's not working.



      Now my guess is that in the routing table is missing a line like this:



      0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlp5s0b1


      In fact, if I run:



      sudo route add default gw 192.168.1.1 wlp5s0b1


      then the routing table is:



      tommy@ubuntu-server:~$ route -n
      Tabella di routing IP del kernel
      Destination Gateway Genmask Flags Metric Ref Use Iface
      0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlp5s0b1
      0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 enp9s0
      192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp9s0
      192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlp5s0b1


      and ping 8.8.8.8 without the ethernet cable work just fine.



      So my question is this: is there a way of keep permanent the route that I added?



      I've already tried to write the command in the last line of the /etc/network/interfaces file, as you can see above, in many different ways:



      • up route add default gw 192.168.1.1

      • up route add default gw 192.168.1.1 wlp5s0b1

      • up route add default gw 192.168.1.1 dev wlp5s0b1

      • as above but with up ip route ...

      • as above but with post-up instead of up

      but it's not working.

      Am I missing the correct syntax or is there any other solution?

      Thanks for your help!









      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 26 at 15:49









      Tommy

      62




      62

























          active

          oldest

          votes











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "89"
          ;
          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',
          convertImagesToLinks: true,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1028462%2fubuntu-server-cannot-add-permanent-static-route%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1028462%2fubuntu-server-cannot-add-permanent-static-route%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Which professions warranted travel in Medieval times?

          How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

          Trouble downloading packages list due to a “Hash sum mismatch” error