A deceptively simple question;

Can Apparmor on Ubuntu (any release) restrict network access for a specific application to a specific network interface?

If it can; an example/tutorial/etc link would be appreciated. Also what happens if the interface disappears (i.e. wifi is disabled etc.)?

If not; are there alternate solutions?

Cheers! / Daniel


Have a look at the ip command, specifically this sub-command netns, i.e. ip netns for setting up namespaces and the associated exec parameter to netns.

$ ip netns help
Usage: ip netns list
       ip netns add NAME
       ip netns set NAME NETNSID
       ip [-all] netns delete [NAME]
       ip netns identify [PID]
       ip netns pids NAME
       ip [-all] netns exec [NAME] cmd ...
       ip netns monitor
       ip netns list-id

For example:

$ ip netns exec ....
  • Welcome to Unix SE :) Could you elaborate your answer with an example ? – Ikaros Jun 13 '18 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.