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)?

  • 12
    The addresses shows are parameters of the IP configuration of the interface. The gateway is a system routing parameter, not an interface parameter. It wouldn't make sense to show it in the interface configuration. Oct 27, 2011 at 10:33

3 Answers 3


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 dev eth0  proto kernel  scope link  src
default via dev eth0
  • 10
    also we can use ip r which shows the same. Jul 31, 2013 at 11:50
  • 11
    So the gateway is '' in this example?
    – xxjjnn
    Aug 21, 2015 at 9:57
  • 7
    route -n is so much cleaner of an output..
    – Angry 84
    Jan 11, 2018 at 22:10
  • 1
    @SenorContento good thing the question was about linux and not a mac.
    – Angry 84
    Aug 3, 2018 at 1:10
  • 4
    For scripting: ip route show | sed 's/\(\S\+\s\+\)\?default via \(\S\+\).*/\2/p; d'
    – user541686
    Jun 2, 2019 at 3:08


$ route

The output is:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         UG    1024   0        0 eth0        *        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).


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .