How to check default gateway and assigned IP address in Linux? There are quite a few ways to do this in a Linux system. However, in systemd or newer version of Linux systems which support the ip route command all the information is there already. The output of the ip route command shows the default gateway and the assigned or primary IP address of the VM or server. Here's an example to show the default gateway of a Linux system. The IP Address after the word "default via" is the default gateway of the system. Command is: ip r | grep default To show only the default gateway IP Address, we need to use RegEx and match the IPV4 address only. Here's the command: ip r | grep default | grep -Eoh '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' Sample output image: To show the assigned primary IP address on the VM or server, type the command below. Here's the command: ip r | grep -oP 'src \K\d+\.\d+\.\d+\.\d+' Sample output imag
Make the world a better place by sharing knowledge, ideas and anything that you can give that comes from the heart.