In order to do ifconfig
in Linux and change the IP and VIP does it require root privileges?
Or it is also possible to do this via a non-root account?
In order to do ifconfig
in Linux and change the IP and VIP does it require root privileges?
Or it is also possible to do this via a non-root account?
You do not need root access to use
ifconfig
to change IP addresses, only CAP_NET_ADMIN. Let's create a copy ofifconfig
withCAP_NET_ADMIN
enabled to see this:Yes, you must be root for use ifconfig since it is usually located in
/usr/sbin
or/sbin
directory. Being non-root, ifconfig binary is not even in your PATH environment variable. So, you should be root, or sudo must be set up. But the modern way is to useip
utility fromiproute2
packet. You could use it under non-privileged user to see info about links, interfaces and routing. However, you must be root to change the settings.This is trivial to test:
So yes, it requires root.