sysctl unable to apply settings on boot

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








up vote
3
down vote

favorite












I followed a tutorial similar to this https://www.niftiestsoftware.com/2011/08/28/making-all-network-traffic-for-a-linux-user-use-a-specific-network-interface/



And started noticing that after a reboot the sysctl system settings weren't applied anymore, specifically these settings from /etc/sysctl.d/999-vpn.conf (also tried putting them in the 99-sysctl.conf file):



net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
net.ipv4.conf.enx002427fe2be7.rp_filter = 2


This is the error in my syslog:



systemd-sysctl[289]: Couldn't write '2' to 'net/ipv4/conf/enx002427fe2be7/rp_filter', ignoring: No such file or directory


enx002427fe2be7 is the network interface name from my USB Network adapter that I use, and I'm guessing that the reason this fails is maybe because it hasnt been initialized yet when the sysctl command runs.



So to fix this I tried an upstart script, but even with exec sleep 60 && sysctl --system this didn't seem to work.



Manually running sysctl --system fixes it, but I'd rather have this automated.



What would be a proper way to fix this?



Using Ubuntu 16.04 LTS Server edition







share|improve this question
























    up vote
    3
    down vote

    favorite












    I followed a tutorial similar to this https://www.niftiestsoftware.com/2011/08/28/making-all-network-traffic-for-a-linux-user-use-a-specific-network-interface/



    And started noticing that after a reboot the sysctl system settings weren't applied anymore, specifically these settings from /etc/sysctl.d/999-vpn.conf (also tried putting them in the 99-sysctl.conf file):



    net.ipv4.conf.all.rp_filter = 2
    net.ipv4.conf.default.rp_filter = 2
    net.ipv4.conf.enx002427fe2be7.rp_filter = 2


    This is the error in my syslog:



    systemd-sysctl[289]: Couldn't write '2' to 'net/ipv4/conf/enx002427fe2be7/rp_filter', ignoring: No such file or directory


    enx002427fe2be7 is the network interface name from my USB Network adapter that I use, and I'm guessing that the reason this fails is maybe because it hasnt been initialized yet when the sysctl command runs.



    So to fix this I tried an upstart script, but even with exec sleep 60 && sysctl --system this didn't seem to work.



    Manually running sysctl --system fixes it, but I'd rather have this automated.



    What would be a proper way to fix this?



    Using Ubuntu 16.04 LTS Server edition







    share|improve this question






















      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      I followed a tutorial similar to this https://www.niftiestsoftware.com/2011/08/28/making-all-network-traffic-for-a-linux-user-use-a-specific-network-interface/



      And started noticing that after a reboot the sysctl system settings weren't applied anymore, specifically these settings from /etc/sysctl.d/999-vpn.conf (also tried putting them in the 99-sysctl.conf file):



      net.ipv4.conf.all.rp_filter = 2
      net.ipv4.conf.default.rp_filter = 2
      net.ipv4.conf.enx002427fe2be7.rp_filter = 2


      This is the error in my syslog:



      systemd-sysctl[289]: Couldn't write '2' to 'net/ipv4/conf/enx002427fe2be7/rp_filter', ignoring: No such file or directory


      enx002427fe2be7 is the network interface name from my USB Network adapter that I use, and I'm guessing that the reason this fails is maybe because it hasnt been initialized yet when the sysctl command runs.



      So to fix this I tried an upstart script, but even with exec sleep 60 && sysctl --system this didn't seem to work.



      Manually running sysctl --system fixes it, but I'd rather have this automated.



      What would be a proper way to fix this?



      Using Ubuntu 16.04 LTS Server edition







      share|improve this question












      I followed a tutorial similar to this https://www.niftiestsoftware.com/2011/08/28/making-all-network-traffic-for-a-linux-user-use-a-specific-network-interface/



      And started noticing that after a reboot the sysctl system settings weren't applied anymore, specifically these settings from /etc/sysctl.d/999-vpn.conf (also tried putting them in the 99-sysctl.conf file):



      net.ipv4.conf.all.rp_filter = 2
      net.ipv4.conf.default.rp_filter = 2
      net.ipv4.conf.enx002427fe2be7.rp_filter = 2


      This is the error in my syslog:



      systemd-sysctl[289]: Couldn't write '2' to 'net/ipv4/conf/enx002427fe2be7/rp_filter', ignoring: No such file or directory


      enx002427fe2be7 is the network interface name from my USB Network adapter that I use, and I'm guessing that the reason this fails is maybe because it hasnt been initialized yet when the sysctl command runs.



      So to fix this I tried an upstart script, but even with exec sleep 60 && sysctl --system this didn't seem to work.



      Manually running sysctl --system fixes it, but I'd rather have this automated.



      What would be a proper way to fix this?



      Using Ubuntu 16.04 LTS Server edition









      share|improve this question











      share|improve this question




      share|improve this question










      asked May 20 at 18:42









      xorinzor

      739




      739




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted
          +50










          A few things come to my mind:



          1. ubuntu 16.04 uses systemd by default instead of upstart. So you could try to write a systemd unit instead of an upstart script


          2. If you use /etc/network/interfaces to manage your network, you could add a line like the following to your interface:



            up sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2


            and remove the corresponding line from your /etc/sysctl.d/999-vpn.conf file.



            If you use NetworkManager there is /etc/NetworkManager/dispatcher.d/ where you can put scripts to execute after a connection is made. Of course in your script you should check that the interface that is brought up is actually your USB adapter.



            if [ "$1" == 'enx002427fe2be7' ] && [ "$2" == 'up' ] ; then
            sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2
            fi


            Alternatively you could put that script in /etc/network/if-up.d/. This should work for both, ifupdown and NetworkManager. (Source: https://askubuntu.com/a/14139/726877). In that case you don't need the up line in /etc/network/interfaces.



            if [ "$IFACE" == 'enx002427fe2be7' ] ; then
            sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2
            fi


            These are just different ways to do the same thing: add the sysctl setting for the network adapter when the network adapter is brought up and therefore available but no sooner.







          share|improve this answer




















          • Thanks! very detailed and informative answer, it worked perfectly as well. I'll award the bounty when the site lets me
            – xorinzor
            May 24 at 10:25










          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%2f1038460%2fsysctl-unable-to-apply-settings-on-boot%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
          3
          down vote



          accepted
          +50










          A few things come to my mind:



          1. ubuntu 16.04 uses systemd by default instead of upstart. So you could try to write a systemd unit instead of an upstart script


          2. If you use /etc/network/interfaces to manage your network, you could add a line like the following to your interface:



            up sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2


            and remove the corresponding line from your /etc/sysctl.d/999-vpn.conf file.



            If you use NetworkManager there is /etc/NetworkManager/dispatcher.d/ where you can put scripts to execute after a connection is made. Of course in your script you should check that the interface that is brought up is actually your USB adapter.



            if [ "$1" == 'enx002427fe2be7' ] && [ "$2" == 'up' ] ; then
            sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2
            fi


            Alternatively you could put that script in /etc/network/if-up.d/. This should work for both, ifupdown and NetworkManager. (Source: https://askubuntu.com/a/14139/726877). In that case you don't need the up line in /etc/network/interfaces.



            if [ "$IFACE" == 'enx002427fe2be7' ] ; then
            sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2
            fi


            These are just different ways to do the same thing: add the sysctl setting for the network adapter when the network adapter is brought up and therefore available but no sooner.







          share|improve this answer




















          • Thanks! very detailed and informative answer, it worked perfectly as well. I'll award the bounty when the site lets me
            – xorinzor
            May 24 at 10:25














          up vote
          3
          down vote



          accepted
          +50










          A few things come to my mind:



          1. ubuntu 16.04 uses systemd by default instead of upstart. So you could try to write a systemd unit instead of an upstart script


          2. If you use /etc/network/interfaces to manage your network, you could add a line like the following to your interface:



            up sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2


            and remove the corresponding line from your /etc/sysctl.d/999-vpn.conf file.



            If you use NetworkManager there is /etc/NetworkManager/dispatcher.d/ where you can put scripts to execute after a connection is made. Of course in your script you should check that the interface that is brought up is actually your USB adapter.



            if [ "$1" == 'enx002427fe2be7' ] && [ "$2" == 'up' ] ; then
            sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2
            fi


            Alternatively you could put that script in /etc/network/if-up.d/. This should work for both, ifupdown and NetworkManager. (Source: https://askubuntu.com/a/14139/726877). In that case you don't need the up line in /etc/network/interfaces.



            if [ "$IFACE" == 'enx002427fe2be7' ] ; then
            sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2
            fi


            These are just different ways to do the same thing: add the sysctl setting for the network adapter when the network adapter is brought up and therefore available but no sooner.







          share|improve this answer




















          • Thanks! very detailed and informative answer, it worked perfectly as well. I'll award the bounty when the site lets me
            – xorinzor
            May 24 at 10:25












          up vote
          3
          down vote



          accepted
          +50







          up vote
          3
          down vote



          accepted
          +50




          +50




          A few things come to my mind:



          1. ubuntu 16.04 uses systemd by default instead of upstart. So you could try to write a systemd unit instead of an upstart script


          2. If you use /etc/network/interfaces to manage your network, you could add a line like the following to your interface:



            up sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2


            and remove the corresponding line from your /etc/sysctl.d/999-vpn.conf file.



            If you use NetworkManager there is /etc/NetworkManager/dispatcher.d/ where you can put scripts to execute after a connection is made. Of course in your script you should check that the interface that is brought up is actually your USB adapter.



            if [ "$1" == 'enx002427fe2be7' ] && [ "$2" == 'up' ] ; then
            sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2
            fi


            Alternatively you could put that script in /etc/network/if-up.d/. This should work for both, ifupdown and NetworkManager. (Source: https://askubuntu.com/a/14139/726877). In that case you don't need the up line in /etc/network/interfaces.



            if [ "$IFACE" == 'enx002427fe2be7' ] ; then
            sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2
            fi


            These are just different ways to do the same thing: add the sysctl setting for the network adapter when the network adapter is brought up and therefore available but no sooner.







          share|improve this answer












          A few things come to my mind:



          1. ubuntu 16.04 uses systemd by default instead of upstart. So you could try to write a systemd unit instead of an upstart script


          2. If you use /etc/network/interfaces to manage your network, you could add a line like the following to your interface:



            up sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2


            and remove the corresponding line from your /etc/sysctl.d/999-vpn.conf file.



            If you use NetworkManager there is /etc/NetworkManager/dispatcher.d/ where you can put scripts to execute after a connection is made. Of course in your script you should check that the interface that is brought up is actually your USB adapter.



            if [ "$1" == 'enx002427fe2be7' ] && [ "$2" == 'up' ] ; then
            sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2
            fi


            Alternatively you could put that script in /etc/network/if-up.d/. This should work for both, ifupdown and NetworkManager. (Source: https://askubuntu.com/a/14139/726877). In that case you don't need the up line in /etc/network/interfaces.



            if [ "$IFACE" == 'enx002427fe2be7' ] ; then
            sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2
            fi


            These are just different ways to do the same thing: add the sysctl setting for the network adapter when the network adapter is brought up and therefore available but no sooner.








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 23 at 22:55









          Lienhart Woitok

          808211




          808211











          • Thanks! very detailed and informative answer, it worked perfectly as well. I'll award the bounty when the site lets me
            – xorinzor
            May 24 at 10:25
















          • Thanks! very detailed and informative answer, it worked perfectly as well. I'll award the bounty when the site lets me
            – xorinzor
            May 24 at 10:25















          Thanks! very detailed and informative answer, it worked perfectly as well. I'll award the bounty when the site lets me
          – xorinzor
          May 24 at 10:25




          Thanks! very detailed and informative answer, it worked perfectly as well. I'll award the bounty when the site lets me
          – xorinzor
          May 24 at 10:25












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1038460%2fsysctl-unable-to-apply-settings-on-boot%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