I need to disable reverse path filtering in Linux. I tried like this
root@user:/home/user# sysctl -w net.ipv4.conf.default.rp_filter=0
now I like to know how to make above settings active so reverse path filtering is disabled do I need to restart sysctl or some thing, Can anyone please tell this
I tried like above but when I ran the sysctl -system
I get this
net.ipv4.conf.default.rp_filter = 2
sysctl: setting key "net.ipv4.conf.all.rp_filter": Invalid argument
why this invalid argument message and I tried changing it to net.ipv4.conf.default.rp_filter = 0 but it still printing sysctl -system as
net.ipv4.conf.default.rp_filter = 2
along with message
There are a few things you've confused,
First, it's
sysctl --systemnotsysctl -systemto reload your configuration files; but that may just be a typo in the question.Second, when you use
sysctl -wto change any setting, that-wmeans writing in the "write instead of readout"-sense, not in the "write to file"-sense. It would only affect the currently active configuration, and it wouldn't be saved anywhere.So when you run
sysctl --systemto reload the system configurationfiles, you undo your priorsysctl -waction.Third, you're presumably trying to change the effective
rp_filtervalue on your system, but thedefaultpart of thenet.ipv4.conf.default.rp_filterkey, means it affects the default value for any unnamed network device that gets created after this point.Presumably, your network device already exists, which means it already has its own personal
rp_filtersetting, and it doesn't care about thedefaultanymore. If your network device is calledeth0, thennet.ipv4.conf.eth0.rp_filteris likely the value you actually wanted to change (withsysctl -wor, by writing that into one of the/etc/sysctl.d/*.conf-style configuration files and then rebooting or reloading the--system).In addition to the
defaultandeth0(or whatever yours is called), there is also anallversion; which is like a wildcard that affects all the existing variants (eg:eth0,eth1andeth2). When your sysctl configuration is loaded during bootup, the networkdevices may or may not exist yet at the time your sysctl configuration is parsed, so it could easily vary ifeth0does or does not exist yet at that time. If it did exist already then theeth0andallvariants would result in the desired affect and thedefaultvariant would not. If however the device didn't exist yet, then it's actually the other way around, anddefaultis the one which would work as intended.To be sure, just change them all/both; in your
/etc/sysctl.confor/etc/sysctl.d/*.conffiles.Update.
Ok, so since you're using a virtual networking device
tun0, which gets created later on, going for thedefaultkey actually wasn't a mistake.The main thing still holds though, you do not want to use both
sysctl -wandsysctl --systemtogether, as the later undoes what the former did.It sounds like you either want something like:
or
Or alternatively, use the
.conffiles; then you can use--systemto reload them.