Categories
Networking

Run Chrome on different network interfaces in Ubuntu

If you have two different internet providers running in single PC, most of time you would like to split the usage between different network interface / adapter.

For instance, you want one browser for browsing and others for downloading / uploading activities. There are several solution to run multiple ethernet network devices like bind-address, firejail and others that may not working easily in Ubuntu

Quick solution for this is to leverage open-source project : https://github.com/JsBergbau/BindToInterface

First, clone the project

git clone https://github.com/JsBergbau/BindToInterface

Second, compile it (make sure to have gcc already installed)

gcc -nostartfiles -fpic -shared bindToInterface.c -o bindToInterface.so -ldl -D_GNU_SOURCE

Third, get your network interfaces information with sudo ifconfig (you can install this as well) and try to get interfaces name. In my case, I have two: enpf0 and enpf1.

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17xxxx  netmask 255.255.0.0  broadcast 172.17.255.255xxx...

enpf0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.xx.xx  netmask 255.255.255.0  broadcast 
        ....

enpf1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.xxxx  netmask 255.255.255.0  broadcast         ....

Now, here is a quick way to run Google Chrome or Firefox with different network interfaces or ethernet with public internet access.

Go inside the github project (or you can copy the .so file) and run this command. Replace enpf1 with your own network interface

BIND_INTERFACE=enpf1 LD_PRELOAD=./bindToInterface.so /usr/bin/google-chrome-stable 

Now you successfully open the google-chrome with specific network interface.

Leave a Reply

Your email address will not be published. Required fields are marked *