Score:1

how to reorder output of "ip address"?

be flag

I'd like to know if it's possible to reorder the sequence of interfaces in the output of the cli command:

ip address

Where is it defined in which order the interfaces are listed?

I have 13 interfaces including bridged interfaces and vlan interfaces.

Their order is arbitrary and I'd like to change that.

I'm using "Network-Manager" and "Advanced Networking Configuration" Tool for configuration.

Raffa avatar
jp flag
Does this answer your question? [How to reset \`ip a\` index to start at \`1\` and end at \`number of devices\`](https://askubuntu.com/questions/1453282/how-to-reset-ip-a-index-to-start-at-1-and-end-at-number-of-devices)
starbuck33 avatar
be flag
No, I asked about where the the order of the output of "ip address" is defined and if this can be changed / adjusted. This answer dosn't give any of that information. But popey answered a part of the question. I guess I was hoping to change the order by text-editing some file but now it seems more complex and I guess I will live with it as is.
Artur Meinild avatar
vn flag
`ip a` and `ip address` is the same command ...
Score:1
pl flag

It comes from /proc/net/dev. For example:

alan@earth:~$ ip address
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
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether d0:bf:9c:45:77:40 brd ff:ff:ff:ff:ff:ff
    altname enp3s0f0
    inet 192.168.0.104/24 metric 100 brd 192.168.0.255 scope global dynamic eno1
       valid_lft 5991sec preferred_lft 5991sec
    inet6 fe80::d2bf:9cff:fe45:7740/64 scope link 
       valid_lft forever preferred_lft forever
3: eno2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether d0:bf:9c:45:77:41 brd ff:ff:ff:ff:ff:ff
    altname enp3s0f1

alan@earth:~$ cat /proc/net/dev
Inter-|   Receive                                                |  Transmit
 face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
    lo: 1070507017 9072512    0    0    0     0          0         0 1070507017 9072512    0    0    0     0       0          0
  eno1: 1669873916763 1133028998    0 2042363    0     0          0   8542737 57824815006 320245927    0    0    0     0       0          0
  eno2:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0

The Linux kernel itself produces this file in net/core/net-procfs.c. See the source here. Here's the snippet.

static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
{
    struct rtnl_link_stats64 temp;
    const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);

    seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
           "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
           dev->name, stats->rx_bytes, stats->rx_packets,
           stats->rx_errors,
           stats->rx_dropped + stats->rx_missed_errors,
           stats->rx_fifo_errors,
           stats->rx_length_errors + stats->rx_over_errors +
            stats->rx_crc_errors + stats->rx_frame_errors,
           stats->rx_compressed, stats->multicast,
           stats->tx_bytes, stats->tx_packets,
           stats->tx_errors, stats->tx_dropped,
           stats->tx_fifo_errors, stats->collisions,
           stats->tx_carrier_errors +
            stats->tx_aborted_errors +
            stats->tx_window_errors +
            stats->tx_heartbeat_errors,
           stats->tx_compressed);
}
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.