You are not logged in.

#1 2019-12-17 12:45:40

DarioP
Member
From: Geneva
Registered: 2011-01-05
Posts: 165

Choose network device per application

Hello, I am running Gnome with network-manager.
I have two network interfaces, both providing internet access, and I would like to attach Firefox to a specific one.

I went as far as learning network namespaces. So my attempt is:

$ sudo ip netns add myns                 # create namespace myns
$ sudo ip link set dev mydev netns myns  # attach mydev to myns
$ ip netns exec myns /usr/bin/firefox    # run firefox inside myns

However the second command fails with:

$ sudo ip link set dev mydev netns myns
RTNETLINK answers: Invalid argument

and I could not find any other hint to progress.
I am open to completely different solutions, but no GUIs please.

Offline

#2 2019-12-17 14:09:28

koffeinfriedhof
Member
Registered: 2017-11-30
Posts: 91

Re: Choose network device per application

Did you replace mydev with your adapter? E.g.

ip link set dev enp0s25 netns whatever

? After adding to your namespace, ip a should not list this device anymore. What is the output of ip -n myns a?

Offline

#3 2019-12-17 21:20:01

DarioP
Member
From: Geneva
Registered: 2011-01-05
Posts: 165

Re: Choose network device per application

I discovered that I can add to the namespace my (unplugged) ethernet interface, but I get the above error with the wireless interface.
Stopping NetworkManager.service and bringing the wireless interface down does not help.

ip -n myns a shows the loopback interface and the ethernet one, the wireless never shows up as

ip link set dev wlp4s0 netns myns

always results in:

RTNETLINK answers: Invalid argument

Offline

#4 2019-12-17 21:44:12

koffeinfriedhof
Member
Registered: 2017-11-30
Posts: 91

Re: Choose network device per application

For wireless you must use iw with the phy. See How to move wireless connection to other network namespace? for an example usage.

Offline

#5 2019-12-17 21:51:02

DarioP
Member
From: Geneva
Registered: 2011-01-05
Posts: 165

Re: Choose network device per application

Thanks a lot for pointing me in the right direction!
I haven't tried yet but that should work properly, although I may also setup a bridge.

Offline

Board footer

Powered by FluxBB