Consider a program server which binds to '*' and listens for incoming connections. I only connect to server from localhost and I do not want external users to be able to connect to it. However, the server program is badly written and does not provide a configuration option or flag to only bind on localhost. Further, it is inconvenient for me to hack the source code of server to fix this.Hence, I would be looking for a wrapper to run server but make it bind on localhost and not on '*'. (For instance, maybe an LD_PRELOAD-based trick could do the job, like tsocks to force the use on a SOCKS proxy on a third-party program.) Does something like this exist? I am root on the machine, if it helps.I know that another solution would be to use iptables for that, but these rules do not persist across reboots so they could silently break. Further, they are global and could be modified by other users of the server, or confuse them. By contrast, when running the server program as wrapper server, I would be more confident that the setup will not break for some other reason.
Wrapper to prevent a program from accessing non-local connections
firewall;tcp