"ip link" 또는 "ip addr"은 이전 인덱스를 출력합니다.

"ip link" 또는 "ip addr"은 이전 인덱스를 출력합니다.

ip link show각 네트워크 인터페이스의 입력 또는 출력 앞에는 인덱스가 옵니다 ip addr show. 예를 들어 여기 1부터 6까지:

root@T42:~# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    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 pfifo_fast state UP qlen 1000
    link/ether 00:16:41:54:01:93 brd ff:ff:ff:ff:ff:ff
3: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN 
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
4: irda0: <NOARP> mtu 2048 qdisc noop state DOWN qlen 8
    link/irda 00:00:00:00 brd ff:ff:ff:ff
5: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:13:ce:8b:99:3e brd ff:ff:ff:ff:ff:ff
6: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 100
    link/none 
root@T42:~# 

이제 인터페이스( ip link del dev tun0)를 삭제하고 인터페이스( ip tuntap add mode tun)를 생성하면 새 인덱스가 사용됩니다.

root@T42:~# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    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 pfifo_fast state UP qlen 1000
    link/ether 00:16:41:54:01:93 brd ff:ff:ff:ff:ff:ff
3: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN 
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
4: irda0: <NOARP> mtu 2048 qdisc noop state DOWN qlen 8
    link/irda 00:00:00:00 brd ff:ff:ff:ff
5: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:13:ce:8b:99:3e brd ff:ff:ff:ff:ff:ff
7: tun0: <POINTOPOINT,MULTICAST,NOARP> mtu 1500 qdisc noop state DOWN qlen 500
    link/none 
root@T42:~# 

이 색인 번호는 무엇을 위해 사용됩니까? 이 색인 번호를 기준으로 정렬하는 방법이 있습니까? 예를 들어, 많은 수의 인터페이스(예: for i in {2..5000}; do brctl addbr br"$i"; done)를 생성하면 인터페이스가 인덱스 번호별로 정렬되지 않습니다.

root@VM-host:~# ip link show | tail
1279: br1246: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/ether 02:de:92:e5:da:b8 brd ff:ff:ff:ff:ff:ff
1023: br990: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/ether c2:35:8b:3a:dd:fa brd ff:ff:ff:ff:ff:ff
767: br734: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/ether da:e9:52:8f:24:dd brd ff:ff:ff:ff:ff:ff
511: br478: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/ether 56:6d:81:a0:71:36 brd ff:ff:ff:ff:ff:ff
255: br222: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/ether a6:92:89:f1:ee:4f brd ff:ff:ff:ff:ff:ff
root@VM-host:~# 

답변1

이 숫자는 편의를 위한 것이며 동적으로 계산됩니다.

이러한 숫자는 동적으로 계산되므로 인터페이스를 참조하는 데 사용해서는 안 됩니다.

더 많은 정보를 확인하실 수 있습니다도구-ip-링크그리고도구 IP 주소.

관련 정보