How can I check the GUI network setting is set DHCP or Static with command line? for the active and connected interface in Ubuntu 18.04
I want one line command like grep give me static/dhcp or true/false
Can use ip
command to check interface you're interested in.
E.g. to check the interface eth0
:
if ip -6 addr show eth0 | grep -q dynamic; then
echo "Uses DHCP addressing"
else
echo "Uses static addressing"
fi
-6
option is for checking IPv6 interface. You can use -4
for IPv4.