Using a different network interface for a specific application

#1 By injecting a custom library

We can use ld_preload function to force the interface gateway with App-Route-Jail

Step 1: the gateway

We need to find what gateway the network interface is using then force that gateway to our jailed application and thus force the application to bind to a specific network interface

$ route
$ route -n
$ ip rule list
$ ip route show
$ netstat -rn
$ cat /etc/network/interfaces
$ cat /etc/sysconfig/network-scripts/ifcfg-eth0
$ traceroute
$ ip route show dev eth0

Step 2: per application gateway

git clone
cd Approute-Utils
chown 755
ip rule add fwmark 10 table 100
ip route add default via table 100
MARK=10 LD_PRELOAD=./ firefox
MARK=10 LD_PRELOAD=./ wget -qO-

#2 By using the Kernel’s namespace feature through firejail

Firejail can force an application to use a specific network, like the following example:

firejail --dns= --net=eth0 --ip=

#3 Alternative:

Additional information on the matter are availables on this SU QA.

Share this post on:

Related posts:

How to scale the desktop's resolution?
How to detach a process from terminal's shell?