Fatal: can't open lock file /run/xtables.lock: Permission denied

Have just subscribed for a VPN service and while I did notice that at times the connection drops, I looked around for ways to setup a kill-switch in Ubuntu. I did follow the instructions at https://linuxconfig.org/how-to-create-a-vpn-killswitch-using-iptables-on-linux but am getting the following issues: (My VPN is setup to OpenVPN)

when running sysctl -p I get the following output:

$ sudo sysctl -p
 net.ipv4.ip_forward = 1
 net.ipv6.conf.all.disable_ipv6 = 1
 net.ipv6.conf.default.disable_ipv6 = 1net.ipv6.conf.lo.disable_ipv6 = 1
 sysctl: cannot stat /proc/sys/net/ipv6/conf/eth0/disable_ipv6: No such             
 file or directory

when it comes to flushing the current IP tables, I get the error:

Fatal: can't open lock file /run/xtables.lock: Permission denied

Would really appreciate some help on this, pls.


1) "No such file or directory" is easy to troubleshoot - just look in your own filesystem. In this case, it's not 'eth0'. It's your actual network connection (likely something like 'tun_' or 'enp___' or 'wlp___').

2) "Permission denied" is also an easy one - it means you forgot to use sudo.