Currently, when using the ifconfig
command, the following IP addresses are shown:
own IP, broadcast and mask.
Is there a way to show the related gateway IP address as well (on the same screen with all the others, not by using 'route' command)?
Currently, when using the ifconfig
command, the following IP addresses are shown:
own IP, broadcast and mask.
Is there a way to show the related gateway IP address as well (on the same screen with all the others, not by using 'route' command)?
You can with the ip
command, and given that ifconfig
is in the process of being deprecated by most distributions it's now the preferred tool. An example:
$ ip route show
212.13.197.0/28 dev eth0 proto kernel scope link src 212.13.197.13
default via 212.13.197.1 dev eth0
ip route show | sed 's/\(\S\+\s\+\)\?default via \(\S\+\).*/\2/p; d'
– user541686
Jun 02 '19 at 03:08
Run:
$ route
The output is:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.0.2.2 0.0.0.0 UG 1024 0 0 eth0
10.0.2.0 * 255.255.255.0 U 0 0 0 eth0
No, there isn't. According to the man page you can't modify the output of ifconfig (except showing disabled interfaces, too).