SOLVED
After some extensive googling, I have found a solution, so I am sharing it here in case anyone needs it.
IMPORTANT NOTES:This solution is actually a workaround, because (at least to my knowledge), NeoRouter Server does
not support binding to a specific address - there is no such setting in its configuration. It always binds to 0.0.0.0.
To use this solution, you need root access to your server and gcc compiler installed.
I have tested it on Debian Jessie - works like a charm.
SOLUTIONWe will need to build a special module (called bind.so) from source. We can use this module then to force any application to bind to any specific IP address. Sounds a little bit scary, but it is actually very simple. This solution works only on IPv4, for IPv6 support you might try
this (I have not tested it, though).
Step 1Download the source code of the bind module, use one of these mirrors:
http://www.ryde.net/code/bind.c.txt or
https://daniel-lange.com/software/bind.cIf you have downloaded source code from the first mirror, rename "bind.c.txt" to "bind.c".
Step 2Compile bind.c (bind.so file will be created), and copy it to /usr/lib:
Code:
gcc -nostartfiles -fpic -shared bind.c -o bind.so -ldl -D_GNU_SOURCE
strip bind.so
cp -i bind.so /usr/lib/
Step 3Now we must change /etc/init.d/nrserver.sh file, which starts/stops NeoRouter Server service.
Open /etc/init.d/nrserver.sh file in you favorite text editor and find these lines:
Code:
start)
log_begin_msg "Starting NeoRouter connection server: $NAME"
start-stop-daemon --start --background -m --pidfile /var/run/nrserver.pid --exec $DAEMON >/dev/null && log_end_msg 0 || log_end_msg 1
;;
Change this block by adding two additional lines of code. Instead of "12.34.56.78" use desired IP address to which NeoRouter Server should bind on start. Please note that BIND_ADDR and LD_PRELOAD variables
must be set with "export" directive.
Code:
start)
log_begin_msg "Starting NeoRouter connection server: $NAME"
export BIND_ADDR="12.34.56.78"
export LD_PRELOAD=/usr/lib/bind.so
start-stop-daemon --start --background -m --pidfile /var/run/nrserver.pid --exec $DAEMON >/dev/null && log_end_msg 0 || log_end_msg 1
;;
Step 4Now restart NeoRouter Server and we are done:
Code:
service nrserver.sh restart
You can verify that everything works with the following command:
Code:
netstat -lntp
If everything works, you should see something like this:
Code:
tcp 0 0 12.34.56.78:32796 0.0.0.0:* LISTEN 4729/nrserver
For some more reading visit links below.
REFERENCES:https://daniel-lange.com/archives/53-Binding-applications-to-a-specific-IP.htmlhttps://github.com/meebey/force_bind <-- this is a similar module which seems to work with IPv6, but I have not tested it. If you try it, please share your experience!