Linux ip kommando oversigt.
ip kommandoen i detaljer. | |
---|---|
Beskrivelse. | Network konfiguration |
Type | netværk |
Sværhedsgrad | Mellem |
Root adgang | ja |
Gemmen læsnings tid | 20m |
|
Det bruges til følgende formål.
- Find ud af, hvilke interface der er konfigureret på systemet.
- Spørg status for en IP-interface.
- Konfigurer den lokale loop-back, Ethernet og andre IP-grænseflader.
- Markér grænsefladen som op eller ned.
- Konfigurer og rediger standard- og statisk routing.
- Indstil tunnel over IP.
- Vis ARP- eller NDISC-cacheindtastning.
- Tildel, slet, opsæt IP-adresse, ruter, undernet og anden IP-information til IP-grænseflader.
- Vis IP-adresser og ejendomsoplysninger.
- Administrer og vis status for alt netværk.
- Saml information om IP-adresser til multicast.
- Vis nabobjekter, dvs. ARP-cache, ugyldig ARP-cache, tilføj en post til ARP-cache og mere.
- Indstil eller slet routingpost.
- Find den rute, en adresse (siger 8.8.8.8 eller 192.168.2.24) tager.
- Rediger status for interface
Lidt lige som ifconfig kommandoen. Der er bare mange flere parametre til ip. Om det er adressen routing eller bond samt andre typer jeg ikke vil komme ind på her. Kommandoen er opbygget sådan at man angiver et object eller type som kan være. { link | address | addrlabel | route | rule | samt flere } Alle disse typer beskriver hvad det er man vil ændre på. Og man kan angive help som argument for at få hjælp til det man vil finde oplysninger på.
Syntax
Object | Abbreviated form | Purpose |
link | l | Netværks device. |
address | a addr | Protocol (IP or IPv6) adresse på device. |
addrlabel | addrl | Label configuration for protocol address selection. |
neighbour | n neigh | ARP or NDISC cache. |
route | r | Routing tabel. |
rule | ru | Regler i routing policy database. |
maddress | m maddr | Multicast address. |
mroute | mr | Multicast routing cache. |
tunnel | t | Tunnel over IP. |
xfrm | x | Framework for IPsec protocol. |
For at få hjælp om de enkelte object typer.
$ ip OBJECT help $ ip OBJECT h $ ip a help $ ip r help
Eksempler
Viser alle netkort info.
$ 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: enp14s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000 link/ether 14:da:e9:2b:01:01 brd ff:ff:ff:ff:ff:ff 3: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 14:da:e9:2b:08:b0 brd ff:ff:ff:ff:ff:ff inet 192.168.0.10/24 brd 192.168.0.255 scope global noprefixroute eno1 valid_lft forever preferred_lft forever inet6 fe80::50e1:be43:cfe2:3dec/64 scope link noprefixroute valid_lft forever preferred_lft forever 4: wlp13s1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:18:e7:5f:b5:13 brd ff:ff:ff:ff:ff:ff inet 192.168.0.177/24 brd 192.168.0.255 scope global dynamic noprefixroute wlp13s1 valid_lft 6914sec preferred_lft 6914sec inet6 fe80::14ea:8cce:1656:d3a/64 scope link noprefixroute valid_lft forever preferred_lft forever
For at se på et enkelt netkort skriver du interface navnet efter show.
$ ip address show dev eno1
For kun at se interfaces som er oppe.
$ ip link ls up
For at tildele en ip adresse til et interface.
For at tilføje ip adresse til et netkort bruges add parameteren til address.
$ sudo ip address add dev virbr0 192.168.2.10
For at fjerne en ip adresse fra et interface.
For at fjerne ip adressen igen bruges del som vist her.
$ sudo ip address del dev virbr0 192.168.2.10
Hvordan ændre man status på netkort.
For at ændre status
ip link set dev {DEVICE} {up|down}
For at lukke interface eth1 ned
$ ip link set dev eth1 down
For at starte interface.
$ ip link set dev eth1 up
Hvordan ændre man MTU på et device.
For gigabit netkort kan det godt betale sig at tillade jumbo frames.
$ ip link set mtu 9000 device eth0 $ ip a list eth0 2: enp14s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 9000 qdisc fq_codel state DOWN group default qlen 1000 link/ether 14:da:e9:2b:01:01 brd ff:ff:ff:ff:ff:ff
Vis nabo arp cache.
Syntax
$ ip n show
$ ip neigh show
74.xx.yy.zz dev eth1 lladdr 00:30:48:yy:zz:ww REACHABLE 10.10.29.66 dev eth0 lladdr 00:30:48:c6:0a:d8 REACHABLE 74.ww.yyy.xxx dev eth1 lladdr 00:1a:30:yy:zz:ww REACHABLE 10.10.29.68 dev eth0 lladdr 00:30:48:33:bc:32 REACHABLE 74.fff.uu.cc dev eth1 lladdr 00:30:48:yy:zz:ww STALE 74.rr.ww.fff dev eth1 lladdr 00:30:48:yy:zz:ww DELAY 10.10.29.65 dev eth0 lladdr 00:1a:30:38:a8:00 REACHABLE 10.10.29.74 dev eth0 lladdr 00:30:48:8e:31:ac REACHABLE
- STALE – The neighbour is valid, but is probably already unreachable, so the kernel will try to check it at the first transmission.
- DELAY – A packet has been sent to the stale neighbour and the kernel is waiting for confirmation.
- REACHABLE – The neighbour is valid and apparently reachable.
Tilføj en ny ARP linje.
Syntax er
ip neigh add {IP-HERE} lladdr {MAC/LLADDRESS} dev {DEVICE} nud {STATE}
In this example, add a permanent ARP entry for the neighbour 192.168.1.5 on the device eth0:
ip neigh add 192.168.1.5 lladdr 00:1a:30:38:a8:00 dev eth0 nud perm
neighbour state (nud) | meaning |
permanent | The neighbour entry is valid forever and can be only be removed administratively |
noarp | The neighbour entry is valid. No attempts to validate this entry will be made but it can be removed when its lifetime expires. |
stale | The neighbour entry is valid but suspicious. This option to ip neigh does not change the neighbour state if it was valid and the address is not changed by this command. |
reachable | The neighbour entry is valid until the reachability timeout expires. |
Slet en ny ARP record.
Syntaks for at ugyldige eller slette en ARP linje for naboen 192.168.1.5 på device eth1 er som følger.
ip neigh del {IPAddress} dev {DEVICE}
ip neigh del 192.168.1.5 dev eth1
Flush ARP entry
For at flush bruges flush eller f kommandoen. så rydes nabo/arp tablen, du kan angive ip adressen:
ip -s -s n f {IPAddress}
Her flusher arp tablen.
ip -s -s n f 192.168.1.5
Eller
ip -s -s n flush 192.168.1.5
Routing table.
For at se route tablen
ip r
ip r list
ip route list
ip r list [options]
ip route
default via 192.168.1.254 dev eth1 192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.10
For at se routing for 192.168.1.0/24:
$ ip r list 192.168.1.0/24
192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.10
Tilføje en ny route.
For at fjerne default gateway.
$ ip route del default
Fjerne en route.
$ ip route del 192.168.1.0/24 dev eth0
For at ændre mac adressen på netkort.
NIC="eno1" ## <-- My NIC name ## ip link show $NIC ip link set dev $NIC down ## set new MAC address ## ip link set dev $NIC address XX:YY:ZZ:AA:BB:CC ip link set dev $NIC up
Her er en table som viser forskellen på ifconfig og ip kommandoen.
Gammel kommando (Deprecated) | Ny kommando |
---|---|
ifconfig -a | ip a |
ifconfig enp6s0 down | ip link set enp6s0 down |
ifconfig enp6s0 up | ip link set enp6s0 up |
ifconfig enp6s0 192.168.2.24 | ip addr add 192.168.2.24/24 dev enp6s0 |
ifconfig enp6s0 netmask 255.255.255.0 | ip addr add 192.168.1.1/24 dev enp6s0 |
ifconfig enp6s0 mtu 9000 | ip link set enp6s0 mtu 9000 |
ifconfig enp6s0:0 192.168.2.25 | ip addr add 192.168.2.25/24 dev enp6s0 |
netstat | ss |
netstat -tulpn | ss -tulpn |
netstat -neopa | ss -neopa |
netstat -g | ip maddr |
route | ip r |
route add -net 192.168.2.0 netmask 255.255.255.0 dev enp6s0 | ip route add 192.168.2.0/24 dev enp6s0 |
route add default gw 192.168.2.254 | ip route add default via 192.168.2.254 |
arp -a | ip neigh |
arp -v | ip -s neigh |
arp -s 192.168.2.33 1:2:3:4:5:6 | ip neigh add 192.168.3.33 lladdr 1:2:3:4:5:6 dev enp6s0 |
arp -i enp6s0 -d 192.168.2.254 | ip neigh del 192.168.2.254 dev wlp7s0 |
Cool blog! Is your theme custom made or did you download it from somewhere?
A design like yours with a few simple adjustements would really make my
blog jump out. Please let me know where you got your theme.
Bless you
I get it from wordpress apperance styles.