Networking – Use LD_PRELOAD to Prevent Network Access

networkingprocess

I'd like to start a program disconnected from the network (because immediately upon starting it tries to download huge amounts of data, which can be prevented by changing settings as soon as it settles down). However, I really don't want to actually bring the network down for this one program.

Is there some LD_PRELOAD or similar to give the program the impression that the network is down? I'd rather not create a virtual machine.

Best Answer

Under Linux, try to use a network namespace, e.g:

sudo ip netns add namespace-name
sudo ip netns exec namespace-name executable

This should prevent the program from accessing the network.

Related Question