1

I need to tell the operating system to allow applications to bind sockets to non-local IP addresses. I want to do that in OpenWrt linux terminal.

Using this command

sysctl net.ipv4.ip_nonlocal_bind

It shows

net.ipv4.ip_nonlocal_bind = 0

However when enabling it

sysctl net.ipv4.ip_nonlocal_bind=1

it gives the error

net.ipv4.ip_nonlocal_bind=1 is an unknown key.

Can anyone solve this problem in OpenWrt?

4
  • Try sysctl -w net.ipv4.ip_nonlocal_bind=1, or try editing the line in /etc/sysctl.conf (I believe) and rebooting. Check that the setting was applied with sysctl net.ipv4.ip_nonlocal_bind.
    – simlev
    Sep 17, 2018 at 7:37
  • @simlev Why didn't you post the -w solution as an answer? I didn't see your edited comment until I answered. If you write your own answer now, I will delete mine and give you credit. Sep 17, 2018 at 7:55
  • @KamilMaciorowski The reason I posted it as a comment is I don't have an OpenWRT system I could test it on. You go ahead this time ;-)
    – simlev
    Sep 17, 2018 at 8:00
  • @simlev Let it be community wiki then. Feel free to add your advice about /etc/sysctl.conf. Sep 17, 2018 at 8:03

1 Answer 1

1

This manual says:

To set a key, use the form variable=value [...] This requires the -w parameter to use.

(It looks like in my Debian -w is not required though; but in my OpenWRT it certainly is). Try:

sysctl -w net.ipv4.ip_nonlocal_bind=1

As an alternative, you can always edit the relevant line in /etc/sysctl.conf and reboot.

At any moment, you can check the current value with sysctl net.ipv4.ip_nonlocal_bind.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .