I have a router with a few hundred network interfaces (most of which virtual, naturally). That means that the output of
ip a
shows very many lines which makes management and analysis difficult. Items 1 to 255 are sorted by item number but from 256 the numbers are calculated mod 256 before sorting them which means they are interleaved (e.g. 256, 257, 1, 258, 2, ...):
# ip a s up
256: veth-99-02@br-vxlan-99-02: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether ab:cd:ef:99:88:77 brd ff:ff:ff:ff:ff:ff
inet 10.2.99.254/24 scope global veth-99-02
valid_lft forever preferred_lft forever
257: vxlan-22-01: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue master br-vxlan-20-01 state UNKNOWN group default qlen 1000
link/ether ab:cd:ef:99:88:77 brd ff:ff:ff:ff:ff:ff
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
258: br-vxlan-22-01: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UP group default qlen 1000
link/ether ab:cd:ef:99:88:77 brd ff:ff:ff:ff:ff:ff
2: eno1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether ab:cd:ef:99:88:66 brd ff:ff:ff:ff:ff:ff
Is there a way to correctly sort this output by number? (They are multi line entries so | sort -n
won't do.)
Or, can I select to display numbers e.g. up to 42?
I tried to select by type (ip a s type ...
) but that does not really work.