sysctl unable to apply settings on boot

Clash 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
networking server
add a comment |Â
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
networking server
add a comment |Â
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
networking server
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
networking server
asked May 20 at 18:42
xorinzor
739
739
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
A few things come to my mind:
- ubuntu 16.04 uses
systemdby default instead ofupstart. So you could try to write asystemdunit instead of anupstartscript If you use
/etc/network/interfacesto manage your network, you could add a line like the following to your interface:up sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2and remove the corresponding line from your
/etc/sysctl.d/999-vpn.conffile.If you use
NetworkManagerthere 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
fiAlternatively you could put that script in
/etc/network/if-up.d/. This should work for both,ifupdownandNetworkManager. (Source: https://askubuntu.com/a/14139/726877). In that case you don't need theupline in/etc/network/interfaces.if [ "$IFACE" == 'enx002427fe2be7' ] ; then
sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2
fiThese are just different ways to do the same thing: add the
sysctlsetting for the network adapter when the network adapter is brought up and therefore available but no sooner.
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
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
A few things come to my mind:
- ubuntu 16.04 uses
systemdby default instead ofupstart. So you could try to write asystemdunit instead of anupstartscript If you use
/etc/network/interfacesto manage your network, you could add a line like the following to your interface:up sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2and remove the corresponding line from your
/etc/sysctl.d/999-vpn.conffile.If you use
NetworkManagerthere 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
fiAlternatively you could put that script in
/etc/network/if-up.d/. This should work for both,ifupdownandNetworkManager. (Source: https://askubuntu.com/a/14139/726877). In that case you don't need theupline in/etc/network/interfaces.if [ "$IFACE" == 'enx002427fe2be7' ] ; then
sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2
fiThese are just different ways to do the same thing: add the
sysctlsetting for the network adapter when the network adapter is brought up and therefore available but no sooner.
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
add a comment |Â
up vote
3
down vote
accepted
A few things come to my mind:
- ubuntu 16.04 uses
systemdby default instead ofupstart. So you could try to write asystemdunit instead of anupstartscript If you use
/etc/network/interfacesto manage your network, you could add a line like the following to your interface:up sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2and remove the corresponding line from your
/etc/sysctl.d/999-vpn.conffile.If you use
NetworkManagerthere 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
fiAlternatively you could put that script in
/etc/network/if-up.d/. This should work for both,ifupdownandNetworkManager. (Source: https://askubuntu.com/a/14139/726877). In that case you don't need theupline in/etc/network/interfaces.if [ "$IFACE" == 'enx002427fe2be7' ] ; then
sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2
fiThese are just different ways to do the same thing: add the
sysctlsetting for the network adapter when the network adapter is brought up and therefore available but no sooner.
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
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
A few things come to my mind:
- ubuntu 16.04 uses
systemdby default instead ofupstart. So you could try to write asystemdunit instead of anupstartscript If you use
/etc/network/interfacesto manage your network, you could add a line like the following to your interface:up sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2and remove the corresponding line from your
/etc/sysctl.d/999-vpn.conffile.If you use
NetworkManagerthere 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
fiAlternatively you could put that script in
/etc/network/if-up.d/. This should work for both,ifupdownandNetworkManager. (Source: https://askubuntu.com/a/14139/726877). In that case you don't need theupline in/etc/network/interfaces.if [ "$IFACE" == 'enx002427fe2be7' ] ; then
sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2
fiThese are just different ways to do the same thing: add the
sysctlsetting for the network adapter when the network adapter is brought up and therefore available but no sooner.
A few things come to my mind:
- ubuntu 16.04 uses
systemdby default instead ofupstart. So you could try to write asystemdunit instead of anupstartscript If you use
/etc/network/interfacesto manage your network, you could add a line like the following to your interface:up sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2and remove the corresponding line from your
/etc/sysctl.d/999-vpn.conffile.If you use
NetworkManagerthere 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
fiAlternatively you could put that script in
/etc/network/if-up.d/. This should work for both,ifupdownandNetworkManager. (Source: https://askubuntu.com/a/14139/726877). In that case you don't need theupline in/etc/network/interfaces.if [ "$IFACE" == 'enx002427fe2be7' ] ; then
sysctl net.ipv4.conf.enx002427fe2be7.rp_filter=2
fiThese are just different ways to do the same thing: add the
sysctlsetting for the network adapter when the network adapter is brought up and therefore available but no sooner.
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
add a comment |Â
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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password