Gostaria de saber se é possível reordenar a sequência de interfaces na saída do comando cli:
ip address
Onde está definido em que ordem as interfaces são listadas?
Tenho 13 interfaces, incluindo interfaces em ponte e interfaces VLAN.
A ordem deles é arbitrária e eu gostaria de mudar isso.
Estou usando a ferramenta "Network-Manager" e "Advanced Networking Configuration" para configuração.
Responder1
Vem de /proc/net/dev
. Por exemplo:
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
O próprio kernel do Linux produz esse arquivo em formato net/core/net-procfs.c
. Veja a fonteaqui. Aqui está o trecho.
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);
}