Reproducing a set of ip commands in netplan

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








up vote
5
down vote

favorite
3












I recently upgraded to ubuntu 18.04 from 16.04 and am trying to figure out how to get my ip route and ip rule commands that I used to put in /etc/network/interfaces working under netplan.



These are the commands that I'm trying to reproduce, that I previously ran in /etc/network/interfaces:



sudo ip rule add table 129 from 192.168.1.160
sudo ip route add table 129 to 204.8.230.0/24 dev enp0s3
sudo ip route add table 129 to 192.168.1.0/24 dev enp0s3
sudo ip route add table 129 default via 192.168.1.1


This is my first pass at the netplan config in /etc/netplan/01-netcfg.yaml:



# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: yes
routes:
- from: 192.168.1.160
to: 204.8.230.0/24
via: 192.168.1.1
- from: 192.168.1.160
to: 192.168.1.0/24
via: 192.168.1.1


However, after a restart those routes do not show up in the ip route output. How do I get these routes to stick?



Note that I've also tried putting these commands in a script in /usr/lib/networkd-dispatcher/routable.d based on some documentation I found, but that does not appear to have worked either.



EDIT: I'm getting closer. This is the new config, but now the problem is that although the table shows up in ip rule, ip route show table 129 is empty:



# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: yes
routing-policy:
- from: 192.168.1.160
table: 129
routes:
- to: 204.8.230.0/24
via: 192.168.1.1
table: 129
- to: 192.168.1.0/24
via: 192.168.1.1
table: 129
- to: 0.0.0.0/0
via: 192.168.1.1
table: 129


I'm on netplan version 0.36.1







share|improve this question


























    up vote
    5
    down vote

    favorite
    3












    I recently upgraded to ubuntu 18.04 from 16.04 and am trying to figure out how to get my ip route and ip rule commands that I used to put in /etc/network/interfaces working under netplan.



    These are the commands that I'm trying to reproduce, that I previously ran in /etc/network/interfaces:



    sudo ip rule add table 129 from 192.168.1.160
    sudo ip route add table 129 to 204.8.230.0/24 dev enp0s3
    sudo ip route add table 129 to 192.168.1.0/24 dev enp0s3
    sudo ip route add table 129 default via 192.168.1.1


    This is my first pass at the netplan config in /etc/netplan/01-netcfg.yaml:



    # This file describes the network interfaces available on your system
    # For more information, see netplan(5).
    network:
    version: 2
    renderer: networkd
    ethernets:
    enp0s3:
    dhcp4: yes
    routes:
    - from: 192.168.1.160
    to: 204.8.230.0/24
    via: 192.168.1.1
    - from: 192.168.1.160
    to: 192.168.1.0/24
    via: 192.168.1.1


    However, after a restart those routes do not show up in the ip route output. How do I get these routes to stick?



    Note that I've also tried putting these commands in a script in /usr/lib/networkd-dispatcher/routable.d based on some documentation I found, but that does not appear to have worked either.



    EDIT: I'm getting closer. This is the new config, but now the problem is that although the table shows up in ip rule, ip route show table 129 is empty:



    # This file describes the network interfaces available on your system
    # For more information, see netplan(5).
    network:
    version: 2
    renderer: networkd
    ethernets:
    enp0s3:
    dhcp4: yes
    routing-policy:
    - from: 192.168.1.160
    table: 129
    routes:
    - to: 204.8.230.0/24
    via: 192.168.1.1
    table: 129
    - to: 192.168.1.0/24
    via: 192.168.1.1
    table: 129
    - to: 0.0.0.0/0
    via: 192.168.1.1
    table: 129


    I'm on netplan version 0.36.1







    share|improve this question
























      up vote
      5
      down vote

      favorite
      3









      up vote
      5
      down vote

      favorite
      3






      3





      I recently upgraded to ubuntu 18.04 from 16.04 and am trying to figure out how to get my ip route and ip rule commands that I used to put in /etc/network/interfaces working under netplan.



      These are the commands that I'm trying to reproduce, that I previously ran in /etc/network/interfaces:



      sudo ip rule add table 129 from 192.168.1.160
      sudo ip route add table 129 to 204.8.230.0/24 dev enp0s3
      sudo ip route add table 129 to 192.168.1.0/24 dev enp0s3
      sudo ip route add table 129 default via 192.168.1.1


      This is my first pass at the netplan config in /etc/netplan/01-netcfg.yaml:



      # This file describes the network interfaces available on your system
      # For more information, see netplan(5).
      network:
      version: 2
      renderer: networkd
      ethernets:
      enp0s3:
      dhcp4: yes
      routes:
      - from: 192.168.1.160
      to: 204.8.230.0/24
      via: 192.168.1.1
      - from: 192.168.1.160
      to: 192.168.1.0/24
      via: 192.168.1.1


      However, after a restart those routes do not show up in the ip route output. How do I get these routes to stick?



      Note that I've also tried putting these commands in a script in /usr/lib/networkd-dispatcher/routable.d based on some documentation I found, but that does not appear to have worked either.



      EDIT: I'm getting closer. This is the new config, but now the problem is that although the table shows up in ip rule, ip route show table 129 is empty:



      # This file describes the network interfaces available on your system
      # For more information, see netplan(5).
      network:
      version: 2
      renderer: networkd
      ethernets:
      enp0s3:
      dhcp4: yes
      routing-policy:
      - from: 192.168.1.160
      table: 129
      routes:
      - to: 204.8.230.0/24
      via: 192.168.1.1
      table: 129
      - to: 192.168.1.0/24
      via: 192.168.1.1
      table: 129
      - to: 0.0.0.0/0
      via: 192.168.1.1
      table: 129


      I'm on netplan version 0.36.1







      share|improve this question














      I recently upgraded to ubuntu 18.04 from 16.04 and am trying to figure out how to get my ip route and ip rule commands that I used to put in /etc/network/interfaces working under netplan.



      These are the commands that I'm trying to reproduce, that I previously ran in /etc/network/interfaces:



      sudo ip rule add table 129 from 192.168.1.160
      sudo ip route add table 129 to 204.8.230.0/24 dev enp0s3
      sudo ip route add table 129 to 192.168.1.0/24 dev enp0s3
      sudo ip route add table 129 default via 192.168.1.1


      This is my first pass at the netplan config in /etc/netplan/01-netcfg.yaml:



      # This file describes the network interfaces available on your system
      # For more information, see netplan(5).
      network:
      version: 2
      renderer: networkd
      ethernets:
      enp0s3:
      dhcp4: yes
      routes:
      - from: 192.168.1.160
      to: 204.8.230.0/24
      via: 192.168.1.1
      - from: 192.168.1.160
      to: 192.168.1.0/24
      via: 192.168.1.1


      However, after a restart those routes do not show up in the ip route output. How do I get these routes to stick?



      Note that I've also tried putting these commands in a script in /usr/lib/networkd-dispatcher/routable.d based on some documentation I found, but that does not appear to have worked either.



      EDIT: I'm getting closer. This is the new config, but now the problem is that although the table shows up in ip rule, ip route show table 129 is empty:



      # This file describes the network interfaces available on your system
      # For more information, see netplan(5).
      network:
      version: 2
      renderer: networkd
      ethernets:
      enp0s3:
      dhcp4: yes
      routing-policy:
      - from: 192.168.1.160
      table: 129
      routes:
      - to: 204.8.230.0/24
      via: 192.168.1.1
      table: 129
      - to: 192.168.1.0/24
      via: 192.168.1.1
      table: 129
      - to: 0.0.0.0/0
      via: 192.168.1.1
      table: 129


      I'm on netplan version 0.36.1









      share|improve this question













      share|improve this question




      share|improve this question








      edited May 10 at 15:32

























      asked May 10 at 14:25









      basepi

      1865




      1865




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          6
          down vote













          I figured it out. The problem was that systemd-networkd was trying to set the routes before the network was up, which was failing. The fix is on-link: True on the routes:



          # This file describes the network interfaces available on your system
          # For more information, see netplan(5).
          network:
          version: 2
          renderer: networkd
          ethernets:
          enp0s3:
          dhcp4: yes
          routing-policy:
          - from: 192.168.1.160
          table: 129
          routes:
          - to: 204.8.230.0/24
          via: 192.168.1.1
          table: 129
          on-link: True
          - to: 192.168.1.0/24
          via: 192.168.1.1
          table: 129
          on-link: True
          - to: 0.0.0.0/0
          via: 192.168.1.1
          table: 129
          on-link: True





          share|improve this answer




















          • Upvoted. Thanks for posting the answer as you will be helping many searchers.
            – chili555
            May 10 at 20:06










          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%2f1034518%2freproducing-a-set-of-ip-commands-in-netplan%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          6
          down vote













          I figured it out. The problem was that systemd-networkd was trying to set the routes before the network was up, which was failing. The fix is on-link: True on the routes:



          # This file describes the network interfaces available on your system
          # For more information, see netplan(5).
          network:
          version: 2
          renderer: networkd
          ethernets:
          enp0s3:
          dhcp4: yes
          routing-policy:
          - from: 192.168.1.160
          table: 129
          routes:
          - to: 204.8.230.0/24
          via: 192.168.1.1
          table: 129
          on-link: True
          - to: 192.168.1.0/24
          via: 192.168.1.1
          table: 129
          on-link: True
          - to: 0.0.0.0/0
          via: 192.168.1.1
          table: 129
          on-link: True





          share|improve this answer




















          • Upvoted. Thanks for posting the answer as you will be helping many searchers.
            – chili555
            May 10 at 20:06














          up vote
          6
          down vote













          I figured it out. The problem was that systemd-networkd was trying to set the routes before the network was up, which was failing. The fix is on-link: True on the routes:



          # This file describes the network interfaces available on your system
          # For more information, see netplan(5).
          network:
          version: 2
          renderer: networkd
          ethernets:
          enp0s3:
          dhcp4: yes
          routing-policy:
          - from: 192.168.1.160
          table: 129
          routes:
          - to: 204.8.230.0/24
          via: 192.168.1.1
          table: 129
          on-link: True
          - to: 192.168.1.0/24
          via: 192.168.1.1
          table: 129
          on-link: True
          - to: 0.0.0.0/0
          via: 192.168.1.1
          table: 129
          on-link: True





          share|improve this answer




















          • Upvoted. Thanks for posting the answer as you will be helping many searchers.
            – chili555
            May 10 at 20:06












          up vote
          6
          down vote










          up vote
          6
          down vote









          I figured it out. The problem was that systemd-networkd was trying to set the routes before the network was up, which was failing. The fix is on-link: True on the routes:



          # This file describes the network interfaces available on your system
          # For more information, see netplan(5).
          network:
          version: 2
          renderer: networkd
          ethernets:
          enp0s3:
          dhcp4: yes
          routing-policy:
          - from: 192.168.1.160
          table: 129
          routes:
          - to: 204.8.230.0/24
          via: 192.168.1.1
          table: 129
          on-link: True
          - to: 192.168.1.0/24
          via: 192.168.1.1
          table: 129
          on-link: True
          - to: 0.0.0.0/0
          via: 192.168.1.1
          table: 129
          on-link: True





          share|improve this answer












          I figured it out. The problem was that systemd-networkd was trying to set the routes before the network was up, which was failing. The fix is on-link: True on the routes:



          # This file describes the network interfaces available on your system
          # For more information, see netplan(5).
          network:
          version: 2
          renderer: networkd
          ethernets:
          enp0s3:
          dhcp4: yes
          routing-policy:
          - from: 192.168.1.160
          table: 129
          routes:
          - to: 204.8.230.0/24
          via: 192.168.1.1
          table: 129
          on-link: True
          - to: 192.168.1.0/24
          via: 192.168.1.1
          table: 129
          on-link: True
          - to: 0.0.0.0/0
          via: 192.168.1.1
          table: 129
          on-link: True






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 10 at 16:22









          basepi

          1865




          1865











          • Upvoted. Thanks for posting the answer as you will be helping many searchers.
            – chili555
            May 10 at 20:06
















          • Upvoted. Thanks for posting the answer as you will be helping many searchers.
            – chili555
            May 10 at 20:06















          Upvoted. Thanks for posting the answer as you will be helping many searchers.
          – chili555
          May 10 at 20:06




          Upvoted. Thanks for posting the answer as you will be helping many searchers.
          – chili555
          May 10 at 20:06












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1034518%2freproducing-a-set-of-ip-commands-in-netplan%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          pylint3 and pip3 broken

          Missing snmpget and snmpwalk

          How to enroll fingerprints to Ubuntu 17.10 with VFS491