cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3470
Views
5
Helpful
9
Replies

show ip route output

abrissonnet
Level 1
Level 1

Hi everyone,

I have a question about the ouput of "show ip route" command. Sometimes, prefixes are shown in two lines like this :

i L2     172.30.112.0/21

           [115/10] via 192.168.255.11, 1w0d, GigabitEthernet0/0/0.11

i L2     172.30.120.0/21

           [115/10] via 192.168.255.12, 1w0d, GigabitEthernet0/0/0.12

i L2     172.30.144.0/22

           [115/10] via 192.168.255.13, 1w0d, GigabitEthernet0/0/0.13

.....

When you have hundreds of routes, I find it illegible. Is it a way to enlarge the screen ("terminal width" command not work), or to filter some part of the output (like interface or time).

Thanks in advance for your answer.

9 Replies 9

Hi,

sh ip route | include

HTH,

Smitesh

Thanks, I already know this command,

I would filter the output to have just one line per prefixe like this :

i L2     172.30.112.0/21 [115/10] via 192.168.255.11, 1w0d, GigabitEthernet0/0/0.11

i L2     172.30.120.0/21 [115/10] via 192.168.255.12, 1w0d, GigabitEthernet0/0/0.12

i L2     172.30.144.0/22 [115/10] via 192.168.255.13, 1w0d, GigabitEthernet0/0/0.13

Is there a command to delete the interface, time, metric (for example) of the output like this :

i L2     172.30.112.0/21 [115/10] via 192.168.255.11, 1w0d or

i L2     172.30.120.0/21 [115/10] via 192.168.255.12, GigabitEthernet0/0/0.12 or

i L2     172.30.144.0/22 via 192.168.255.13, 1w0d, GigabitEthernet0/0/0.13

Thanks in advance

You can have multiple pipes for your first requirement.

eg,

sh ip route | i 172.30.112.0|172.30.120.0| 172.30.120.0

You can't have the output as you wanted as in your second requirement.

HTH,

Smitesh

Smitesh,

You are correct but you have to be careful: the | sign is used both as a pipe and as a string-OR operator.

The first | sign is a pipe - you are taking the output of the show ip route command and directing it to the input of the include command. However, all subsequent occurences of the | character are considered as OR operator in regular expression. The command as you have suggested says:

I want to see all lines containing the string 172.30.112.0 or the string 172.30.120.0 or the string 172.30.144.0 (you've probably made a small typo there).

This is in strong difference to operating systems where subsequent usage of the | operator means creating a pipeline, i.e. a set of producer/consumer processes processing the output of the predecessing command and feeding it to another.

Best regards,

Peter

Hi Peter,

Thanks for pointing, however I didn't understood when you said "you've probably made a small typo there".

As per the requirement, which is X OR Y OR Z i suggest sh ip route | include X|Y|Z

Apologies, if I'm misinterpretrating something wrong.

Regards,

Smitesh

Hi Smitesh,

You suggested:

sh ip route | i 172.30.112.0|172.30.120.0| 172.30.120.0

Note that the network 172.30.120.0 is indicated twice in this output. Correctly, one of the networks should have been 172.30.144.0. That's the typo I referred to. Don't worry about that

Best regards,

Peter

Ahh...

Yeah typo mistake as you said...

Regards,

Smitesh

paulhieb1
Level 1
Level 1

An Annoying problem indeed, which after 6 years still we have no answer.

One workaround I've found helpful is to view the CEF table, which has a much more readable and filterable structure (and actually outputs a Table like structure)... the only problem is you don't get the source protocol of the route or metric information. But at least it's useable programatically and can give field to index loop through for other commands like "show ip (proto) topo (index)".

SP04S1#sh ip cef | ex /32
Prefix Next Hop Interface
0.0.0.0/0 172.18.0.13 Vlan1
0.0.0.0/8 drop
10.0.0.0/8 172.18.0.13 Vlan1
10.0.0.0/24 172.18.0.13 Vlan1
10.0.19.0/24 x.x.x.x TenGigabitEthernet6/1
10.0.22.0/24 172.16.99.253 Vlan99
10.1.0.0/24 x.x.x.x TenGigabitEthernet6/1
10.2.0.0/24 x.x.x.x TenGigabitEthernet6/1
10.4.0.0/24 attached Vlan50
10.10.16.0/24 172.18.0.13 Vlan1
10.33.0.0/16 192.168.114.1 Vlan35
10.104.0.0/24 172.18.0.13 Vlan1
10.192.22.0/24 172.16.99.253 Vlan99

4 years later and still no solution.

Review Cisco Networking for a $25 gift card