Ip/Befehl: Unterschied zwischen den Versionen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 35: | Zeile 35: | ||
| | | | ||
|- | |- | ||
| IP Adressen entfernen | | Alle IP Adressen entfernen | ||
| ip addr flush dev DEVICE|<code>ip addr flush dev DEVICE</code> | | ip addr flush dev DEVICE|<code>ip addr flush dev DEVICE</code> | ||
| <code>ip a f dev DEVICE</code> | | <code>ip a f dev DEVICE</code> |
Version vom 23. August 2019, 11:07 Uhr
Das Kommando ip aus der iproute2 Toolsammlung dient unter Linux zur Konfiguration von Netzwerkadressen. Es ersetzt das ifconfig Kommando aus den obsoleten net-tools. Dieser Artikel zeigt die wichtigsten Parameter des ip Kommandos anhand einiger Beispiele.
Vergleichstabelle ip versus ifconfig
Die Tabelle zeigt wichtige Befehle zur Netzwerkkonfiguration und vergleicht die Syntax der Kommandos ip und ifconfig:
Zweck | iproute2 Kommando | iproute2 Kommando Kurzversion | net-tools Kommando |
---|---|---|---|
Linkstatus anzeigen | ip link show
|
ip l
|
ifconfig
|
Linkstatus inkl. Statistik (RX/TX bytes, errors, ...) anzeigen |
ip -statistics link show
|
ip -s l
|
ifconfig
|
IP Adresse anzeigen | ip addr show
|
ip a
|
ifconfig -a
|
IP Adresse setzen | ip addr add IP/NETMASK dev DEVICE
|
ip a a IP/NETMASK dev DEVICE
|
ifconfig DEVICE IP/NETMASK
|
IP Adresse entfernen | ip addr del IP/NETMASK dev DEVICE
|
ip a d IP/NETMASK dev DEVICE
|
|
Alle IP Adressen entfernen | ip addr flush dev DEVICE
|
ip a f dev DEVICE
|
|
Routingtabelle anzeigen | ip route show
|
ip r
|
route -n
|
Standardgateway setzen | ip route add default via IP
|
ip r a default via IP
|
route add default gw IP DEVICE
|
ARP-Cache anzeigen | ip neigh show
|
ip n
|
arp -na
|
Verbindungen anzeigen | ss --tcp --all --processes --extended --numeric
|
ss -tapen
|
netstat -tapen
|
Beispiele
Die folgenden Ausgaben zeigen einige Beispiele von iproute2 Kommandos.
ip help
$ ip help Usage: ip [ OPTIONS ] OBJECT { COMMAND | help } ip [ -force ] -batch filename where OBJECT := { link | addr | addrlabel | route | rule | neigh | ntable | tunnel | tuntap | maddr | mroute | mrule | monitor | xfrm | netns } OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] | -f[amily] { inet | inet6 | ipx | dnet | link } | -l[oops] { maximum-addr-flush-attempts } | -o[neline] | -t[imestamp] | -b[atch] [filename] | -rc[vbuf] [size]}
ip link show
$ ip link show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 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 08:00:27:66:72:e1 brd ff:ff:ff:ff:ff:ff
ip -statistics link show
$ ip link show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 RX: bytes packets errors dropped overrun mcast 2073916 4895 0 0 0 0 TX: bytes packets errors dropped carrier collsns 2073916 4895 0 0 0 0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:66:72:e1 brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped overrun mcast 1716782262 1369751 0 0 0 0 TX: bytes packets errors dropped carrier collsns 308636400 1172428 0 0 0 0
ip addr show
$ ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 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 pfifo_fast state UP qlen 1000 link/ether 08:00:27:66:72:e1 brd ff:ff:ff:ff:ff:ff inet 10.1.102.59/24 brd 10.1.102.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::a00:27ff:fe66:72e1/64 scope link valid_lft forever preferred_lft forever
ip addr add IP/NETMASK dev DEVICE
$ sudo ip addr add 10.1.102.60/24 dev eth0 $ ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 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 pfifo_fast state UP qlen 1000 link/ether 08:00:27:66:72:e1 brd ff:ff:ff:ff:ff:ff inet 10.1.102.59/24 brd 10.1.102.255 scope global eth0 valid_lft forever preferred_lft forever inet 10.1.102.60/24 scope global secondary eth0 valid_lft forever preferred_lft forever inet6 fe80::a00:27ff:fe66:72e1/64 scope link valid_lft forever preferred_lft forever
ip addr del IP/NETMASK dev DEVICE
$ sudo ip addr del 10.1.102.60/24 dev eth0 $ ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 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 pfifo_fast state UP qlen 1000 link/ether 08:00:27:15:17:5e brd ff:ff:ff:ff:ff:ff inet 10.1.102.54/24 brd 10.1.102.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::a00:27ff:fe15:175e/64 scope link valid_lft forever preferred_lft forever
ip addr flush dev DEVICE
$ sudo ip addr flush dev eth0 $ ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 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 pfifo_fast state UP qlen 1000 link/ether 08:00:27:15:17:5e brd ff:ff:ff:ff:ff:ff
ip route show
$ ip route show default via 10.1.102.1 dev eth0 metric 100 10.1.102.0/24 dev eth0 proto kernel scope link src 10.1.102.59
ip route add default via IP
$ sudo ip route add d via 10.1.102.1
ip neigh show
$ ip neigh show 10.1.102.101 dev eth0 lladdr f0:de:f1:f3:17:88 REACHABLE 10.1.102.1 dev eth0 lladdr 00:0c:42:97:79:63 REACHABLE