Linux: Allow Normal Users To Take Down eth1:N But Not eth1 Itself

To allow normal users to take down a specific network interface, such as eth1:N but not the parent interface eth1, you can use the sudo command in combination with the ip command.

Here are the steps to allow normal users to take down eth1:N but not eth1:

  1. Create a new group: Create a new group with a name of your choice, for example network_admin.
sudo groupadd network_admin
  1. Add users to the new group: Add the users who should have permission to take down eth1:N to the new group.
sudo usermod -a -G network_admin username
  1. Create a new sudo rule: Create a new sudo rule in the /etc/sudoers file to allow members of the network_admin group to run the ip command with the link set option on the eth1:N interface, but not on the eth1 interface.
%network_admin ALL=(ALL) NOPASSWD: /sbin/ip link set eth1:* down
  1. Verify the new sudo rule: Verify that the new sudo rule is working by logging in as a user who is a member of the network_admin group, and attempting to take down the eth1:N interface.
sudo ip link set eth1:N down

If the new sudo rule is working correctly, the eth1:N interface should be taken down, but attempting to take down the eth1 interface should fail with a Permission denied error.

Note that these steps may vary depending on the specific Linux distribution and version that you are using. If you encounter any issues or have questions about allowing normal users to take down a specific network interface, you may want to consult the documentation for your Linux distribution or consult with a knowledgeable Linux user for assistance.

(https://theownerbuildernetwork.co)

Leave a Comment