1

When using route command, -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 default.

3

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.

The 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 route's -n.

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".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.