-n switch does the trick. How to get numerical output using
ip route command? It's man page does not mention anything similar. Specifically I need
0.0.0.0 instead of
The purpose of the
-n option of
route is to suppress address-to-name lookups. It can be used for example to get the raw numerical information in case the lookups are too slow or returning incorrect results.
ip command doesn't do address-to-name lookups by default, so it doesn't have or need that option. It does show the
0.0.0.0/0 entry as
default for increased clarity, but that's just hardcoded, it's not based on a name lookup. There is a
-r option to ask
ip to resolve addresses to names, but it's not enabled by default. Essentially,
-r is the opposite of
You can always pipe the output through
sed s#default#0.0.0.0/0# if you don't want to see the word "default".