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 of
CAP_NET_ADMIN enabled to see this:
cp /sbin/ifconfig . sudo setcap cap_net_admin=eip ./ifconfig ./ifconfig eth0 220.127.116.11 # succeeds # Wouldn't want to leave this copy of ifconfig around, # It's a security hole! rm ifconfig
Yes, you must be root for use ifconfig since it is usually located in
/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 use
ip utility from
iproute2 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.