Open waketzheng opened 1 month ago
Thanks for the PR, I will have to look into it more closely - I want to make sure this matches the output on linux.
Could you please post here comparable output of your script and output on some linux distro? Thanks
python src/ip.py link
1: lo0: <UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 status UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: gif0: <POINTOPOINT,MULTICAST> mtu 1280 status UNKNOWN
link/none
3: stf0: <> mtu 1280 status UNKNOWN
link/unknown
4: en0: <UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 status UP
link/ether b8:e8:56:45:5a:40 brd ff:ff:ff:ff:ff:ff
5: en1: <UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 status DOWN
link/ether 82:0f:02:80:5d:00 brd ff:ff:ff:ff:ff:ff
6: en2: <UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 status DOWN
link/ether 82:0f:02:80:5d:01 brd ff:ff:ff:ff:ff:ff
7: bridge0: <UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 status DOWN
link/ether 82:0f:02:80:5d:00 brd ff:ff:ff:ff:ff:ff
8: p2p0: <UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304 status DOWN
link/ether 0a:e8:56:45:5a:40 brd ff:ff:ff:ff:ff:ff
9: awdl0: <UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484 status UP
link/ether aa:e9:7b:b1:93:ca brd ff:ff:ff:ff:ff:ff
10: llw0: <UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 status UP
link/ether aa:e9:7b:b1:93:ca brd ff:ff:ff:ff:ff:ff
11: utun0: <UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380 status UNKNOWN
link/none
12: utun1: <UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000 status UNKNOWN
link/none
python src/ip.py -o link
1: lo0: <UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 status UNKNOWN\ link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: gif0: <POINTOPOINT,MULTICAST> mtu 1280 status UNKNOWN\ link/none
3: stf0: <> mtu 1280 status UNKNOWN\ link/unknown
4: en0: <UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 status UP\ link/ether b8:e8:56:45:5a:40 brd ff:ff:ff:ff:ff:ff
5: en1: <UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 status DOWN\ link/ether 82:0f:02:80:5d:00 brd ff:ff:ff:ff:ff:ff
6: en2: <UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 status DOWN\ link/ether 82:0f:02:80:5d:01 brd ff:ff:ff:ff:ff:ff
7: bridge0: <UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 status DOWN\ link/ether 82:0f:02:80:5d:00 brd ff:ff:ff:ff:ff:ff
8: p2p0: <UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304 status DOWN\ link/ether 0a:e8:56:45:5a:40 brd ff:ff:ff:ff:ff:ff
9: awdl0: <UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484 status UP\ link/ether aa:e9:7b:b1:93:ca brd ff:ff:ff:ff:ff:ff
10: llw0: <UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 status UP\ link/ether aa:e9:7b:b1:93:ca brd ff:ff:ff:ff:ff:ff
11: utun0: <UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380 status UNKNOWN\ link/none
12: utun1: <UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000 status UNKNOWN\ link/none
ip addr
1: lo0: <UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 status UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8
inet6 ::1/128
inet6 fe80::1/64
2: gif0: <POINTOPOINT,MULTICAST> mtu 1280 status UNKNOWN
link/none
3: stf0: <> mtu 1280 status UNKNOWN
link/unknown
4: en0: <UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 status UP
link/ether b8:e8:56:45:5a:40 brd ff:ff:ff:ff:ff:ff
inet6 fe80::858:6a05:a30b:fb63/64
inet 7.249.178.166/23 brd 7.249.179.255
5: en1: <UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 status DOWN
link/ether 82:0f:02:80:5d:00 brd ff:ff:ff:ff:ff:ff
6: en2: <UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 status DOWN
link/ether 82:0f:02:80:5d:01 brd ff:ff:ff:ff:ff:ff
7: bridge0: <UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 status DOWN
link/ether 82:0f:02:80:5d:00 brd ff:ff:ff:ff:ff:ff
8: p2p0: <UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304 status DOWN
link/ether 0a:e8:56:45:5a:40 brd ff:ff:ff:ff:ff:ff
9: awdl0: <UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484 status UP
link/ether aa:e9:7b:b1:93:ca brd ff:ff:ff:ff:ff:ff
inet6 fe80::a8e9:7bff:feb1:93ca/64
10: llw0: <UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 status UP
link/ether aa:e9:7b:b1:93:ca brd ff:ff:ff:ff:ff:ff
inet6 fe80::a8e9:7bff:feb1:93ca/64
11: utun0: <UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380 status UNKNOWN
link/none
inet6 fe80::becb:e0ba:3ce3:e6c7/64
12: utun1: <UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000 status UNKNOWN
link/none
inet6 fe80::5eb0:37b5:c492:d7cf/64
python src/ip.py -o addr
1: lo0: <UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 status UNKNOWN\ link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00\ inet 127.0.0.1/8\ inet6 ::1/128\ inet6 fe80::1/64
2: gif0: <POINTOPOINT,MULTICAST> mtu 1280 status UNKNOWN\ link/none
3: stf0: <> mtu 1280 status UNKNOWN\ link/unknown
4: en0: <UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 status UP\ link/ether b8:e8:56:45:5a:40 brd ff:ff:ff:ff:ff:ff\ inet6 fe80::858:6a05:a30b:fb63/64\ inet 7.249.178.166/23 brd 7.249.179.255
5: en1: <UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 status DOWN\ link/ether 82:0f:02:80:5d:00 brd ff:ff:ff:ff:ff:ff
6: en2: <UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 status DOWN\ link/ether 82:0f:02:80:5d:01 brd ff:ff:ff:ff:ff:ff
7: bridge0: <UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 status DOWN\ link/ether 82:0f:02:80:5d:00 brd ff:ff:ff:ff:ff:ff
8: p2p0: <UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304 status DOWN\ link/ether 0a:e8:56:45:5a:40 brd ff:ff:ff:ff:ff:ff
9: awdl0: <UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484 status UP\ link/ether aa:e9:7b:b1:93:ca brd ff:ff:ff:ff:ff:ff\ inet6 fe80::a8e9:7bff:feb1:93ca/64
10: llw0: <UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 status UP\ link/ether aa:e9:7b:b1:93:ca brd ff:ff:ff:ff:ff:ff\ inet6 fe80::a8e9:7bff:feb1:93ca/64
11: utun0: <UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380 status UNKNOWN\ link/none\ inet6 fe80::becb:e0ba:3ce3:e6c7/64
12: utun1: <UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000 status UNKNOWN\ link/none\ inet6 fe80::5eb0:37b5:c492:d7cf/64
~ » cat /etc/issue
Ubuntu 22.04.4 LTS \n \l
ip link
)
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 00:16:3e:10:7a:6c brd ff:ff:ff:ff:ff:ff
altname enp0s5
altname ens5
3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default
link/ether 02:42:43:fb:1d:cd brd ff:ff:ff:ff:ff:ff
4: br-5f24f722517c: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default
link/ether 02:42:3a:b8:97:a8 brd ff:ff:ff:ff:ff:ff
32: vethf2e447c@if31: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP mode DEFAULT group default
link/ether ba:21:0a:94:43:f0 brd ff:ff:ff:ff:ff:ff link-netnsid 2
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000\ link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000\ link/ether 00:16:3e:10:7a:6c brd ff:ff:ff:ff:ff:ff\ altname enp0s5\ altname ens5
3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default \ link/ether 02:42:43:fb:1d:cd brd ff:ff:ff:ff:ff:ff
4: br-5f24f722517c: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default \ link/ether 02:42:3a:b8:97:a8 brd ff:ff:ff:ff:ff:ff
32: vethf2e447c@if31: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP mode DEFAULT group default \ link/ether ba:21:0a:94:43:f0 brd ff:ff:ff:ff:ff:ff link-netnsid 2
ip addr
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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:16:3e:10:7a:6c brd ff:ff:ff:ff:ff:ff
altname enp0s5
altname ens5
inet 172.22.42.25/18 metric 100 brd 172.22.63.255 scope global dynamic eth0
valid_lft 307133302sec preferred_lft 307133302sec
inet6 fe80::216:3eff:fe10:7a6c/64 scope link
valid_lft forever preferred_lft forever
3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:43:fb:1d:cd brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::42:43ff:fefb:1dcd/64 scope link
valid_lft forever preferred_lft forever
4: br-5f24f722517c: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:3a:b8:97:a8 brd ff:ff:ff:ff:ff:ff
inet 172.18.0.1/16 brd 172.18.255.255 scope global br-5f24f722517c
valid_lft forever preferred_lft forever
inet6 fe80::42:3aff:feb8:97a8/64 scope link
valid_lft forever preferred_lft forever
32: vethf2e447c@if31: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default
link/ether ba:21:0a:94:43:f0 brd ff:ff:ff:ff:ff:ff link-netnsid 2
inet6 fe80::b821:aff:fe94:43f0/64 scope link
valid_lft forever preferred_lft forever
ip -o addr
1: lo inet 127.0.0.1/8 scope host lo\ valid_lft forever preferred_lft forever
1: lo inet6 ::1/128 scope host \ valid_lft forever preferred_lft forever
2: eth0 inet 172.22.42.25/18 metric 100 brd 172.22.63.255 scope global dynamic eth0\ valid_lft 307133237sec preferred_lft 307133237sec
2: eth0 inet6 fe80::216:3eff:fe10:7a6c/64 scope link \ valid_lft forever preferred_lft forever
3: docker0 inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0\ valid_lft forever preferred_lft forever
3: docker0 inet6 fe80::42:43ff:fefb:1dcd/64 scope link \ valid_lft forever preferred_lft forever
4: br-5f24f722517c inet 172.18.0.1/16 brd 172.18.255.255 scope global br-5f24f722517c\ valid_lft forever preferred_lft forever
4: br-5f24f722517c inet6 fe80::42:3aff:feb8:97a8/64 scope link \ valid_lft forever preferred_lft forever
32: vethf2e447c inet6 fe80::b821:aff:fe94:43f0/64 scope link \ valid_lft forever preferred_lft forever
Closes #17