IP(8)

๐Ÿ“ฆ
version 7.3.0 ยท 3 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

โœจ NAME โœจ

Okay so the manual name here is ip, and it's the Swiss Army knife for networking ๐Ÿ”ชโœจ. It lets you show and manipulate routing, network devices, interfaces and tunnels. Literally everything networky, bestie ๐Ÿ’…

๐ŸŒธ SYNOPSIS ๐ŸŒธ

Here's how you call it ๐Ÿซถ

ip [ OPTIONS ] OBJECT { COMMAND | help }

ip [ -force ] -batch filename

OBJECT := { address | addrlabel | fou | help | ila | ioam | l2tp | link
        | macsec | maddress | monitor | mptcp | mroute | mrule |
        neighbor | neighbour | netconf | netns | nexthop | ntable | ntbl
        | route | rule | sr | tap | tcpmetrics | token | tunnel | tuntap
        | vrf | xfrm }

OPTIONS := { -V[ersion] | -h[uman-readable] | -s[tatistics] | -d[etails]
        | -r[esolve] | -iec | -f[amily] { inet | inet6 | link } | -4 |
        -6 | -B | -0 | -l[oops] { maximum-addr-flush-attempts } |
        -o[neline] | -rc[vbuf] [size] | -t[imestamp] | -ts[hort] |
        -n[etns] name | -N[umeric] | -a[ll] | -c[olor] | -br[ief] |
        -j[son] | -p[retty] }

๐ŸŽ€ OPTIONS ๐ŸŽ€

Okay, these are the flags you can slap on the end of your command ๐Ÿ’–

  • -V, -Version โ€” Prints the version of the ip utility and then exits. Bye bye ๐Ÿ‘‹
  • -h, -human, -human-readable โ€” Shows statistics with human readable values, followed by a suffix. So much easier to read ๐Ÿฅน
  • -b, -batch <FILENAME> โ€” Reads commands from the file you give it (or standard input) and runs them. Heads up: the first failure kills ip dead ๐Ÿ’€
  • -force โ€” Don't terminate ip on errors in batch mode ๐Ÿ™ˆ But if any errors happened while running the commands, the return code of the application will be non zero, so you'll still know something went wrong.
  • -s, -stats, -statistics โ€” Outputs more info. Repeat it twice or more and the info keeps growing ๐Ÿ“ˆ As a rule, the extra stuff is statistics or some time values.
  • -d, -details โ€” Outputs more detailed info ๐Ÿ”
  • -l, -loops <COUNT> โ€” Sets the max number of loops the ip address flush logic will try before giving up. The default is 10. Zero (0) means keep looping until every address is gone ๐Ÿงน
  • -f, -family <FAMILY> โ€” Picks the protocol family to use. It can be inet, inet6, bridge, mpls or link. If you skip this, the family gets guessed from your other arguments. If there still isn't enough info to guess, ip falls back to the default one, which is usually inet or any. Oh, and link is a special one that means no networking protocol is involved at all ๐Ÿฆ‹
  • -4 โ€” shortcut for -family inet
  • -6 โ€” shortcut for -family inet6
  • -B โ€” shortcut for -family bridge
  • -M โ€” shortcut for -family mpls
  • -0 โ€” shortcut for -family link
  • -o, -oneline โ€” Outputs each record on a single line, swapping line feeds for the \ character. This is so convenient when you want to count records with wc(1) or search them with grep(1) ๐Ÿงš
  • -r, -resolve โ€” Uses the system's name resolver to print DNS names instead of host addresses ๐ŸŒ
  • -n, -netns <NETNS> โ€” Switches ip to the network namespace you name, NETNS. This is basically a shortcut for the long way of running it. So instead of typing this:
ip netns exec NETNS ip [ OPTIONS ] OBJECT { COMMAND | help }

you can just type this:

ip -n[etns] NETNS [ OPTIONS ] OBJECT { COMMAND | help }
  • -N, -Numeric โ€” Prints the number of the protocol, scope, dsfield, etc. directly, instead of turning it into a human readable name ๐Ÿ”ข
  • -a, -all โ€” Runs the specified command over all objects. Whether it works depends on if the command supports this option ๐Ÿคทโ€โ™€๏ธ
  • -c[color][={always|auto|never} โ€” Configures color output ๐ŸŒˆ If you leave the parameter out, or pick always, color output is on no matter what stdout is doing. If you pick auto, stdout gets checked to see if it's a terminal before color turns on. If you pick never, color is off. If you use this flag more than once, the last one wins. This flag gets ignored if -json is also given.

The color palette can be influenced by the COLORFGBG environment variable (see ENVIRONMENT).

  • -t, -timestamp โ€” Displays the current time when you use the monitor option โฐ
  • -ts, -tshort โ€” Same as -timestamp, but with a shorter format โฑ๏ธ
  • -rc, -rcvbuf<SIZE> โ€” Sets the netlink socket receive buffer size. It defaults to 1MB ๐Ÿ“ฆ
  • -iec โ€” Prints human readable rates in IEC units (e.g. 1Ki = 1024) ๐Ÿงฎ
  • -br, -brief โ€” Prints only the basic info in a tabular format, which is way easier to read. Right now this only works with ip addr show, ip link show & ip neigh show ๐Ÿ“‹
  • -j, -json โ€” Outputs results in JavaScript Object Notation (JSON) ๐Ÿ’œ
  • -p, -pretty โ€” The default JSON format is compact and super efficient to parse, but honestly kinda hard for most humans to read. This flag adds indentation so it's readable ๐ŸŽ€
  • -echo โ€” Asks the kernel to send the applied configuration back to you ๐Ÿชž

โœจ IP - COMMAND SYNTAX โœจ

๐Ÿฆ‹ OBJECT

These are the things you can poke at ๐Ÿ‘€

  • address โ€” a protocol (IP or IPv6) address on a device ๐Ÿ 
  • addrlabel โ€” label configuration for protocol address selection ๐Ÿท๏ธ
  • fou โ€” Foo-over-UDP receive port configuration ๐ŸŒŠ
  • ila โ€” manages identifier locator addresses (ILA) ๐Ÿ“
  • ioam โ€” manages IOAM namespaces and IOAM schemas ๐Ÿงฉ
  • l2tp โ€” tunnels ethernet over IP (L2TPv3) ๐Ÿš‡
  • link โ€” a network device ๐Ÿ”Œ
  • macsec โ€” MACsec device configuration ๐Ÿ”
  • maddress โ€” a multicast address ๐Ÿ“ฃ
  • monitor โ€” watches for netlink messages ๐Ÿ‘€
  • mptcp โ€” manages the MPTCP path manager ๐Ÿ›ค๏ธ
  • mroute โ€” a multicast routing cache entry ๐Ÿ—บ๏ธ
  • mrule โ€” a rule in the multicast routing policy database ๐Ÿ“œ
  • neighbour โ€” manages ARP or NDISC cache entries ๐Ÿค
  • netconf โ€” network configuration monitoring ๐Ÿ“ก
  • netns โ€” manages network namespaces ๐Ÿซง
  • nexthop โ€” manages nexthop objects โžก๏ธ
  • ntable โ€” manages the neighbor cache's operation ๐Ÿง 
  • route โ€” a routing table entry ๐Ÿ›ฃ๏ธ
  • rule โ€” a rule in the routing policy database ๐Ÿ“
  • sr โ€” manages IPv6 segment routing ๐Ÿงญ
  • stats โ€” manages and shows interface statistics ๐Ÿ“Š
  • tcp_metrics/tcpmetrics โ€” manages TCP Metrics ๐Ÿ“ˆ
  • token โ€” manages tokenized interface identifiers ๐Ÿช™
  • tunnel โ€” a tunnel over IP ๐Ÿ•ณ๏ธ
  • tuntap โ€” manages TUN/TAP devices ๐Ÿš
  • vrf โ€” manages virtual routing and forwarding devices ๐Ÿฐ
  • xfrm โ€” manages IPSec policies ๐Ÿ”’

The names of all objects can be written in full or abbreviated. For example, address can be shortened to addr or just a โœ‚๏ธ

๐Ÿ’… COMMAND

This is the action you want to do to the object ๐ŸŽฏ The list of possible actions depends on the object type. As a rule, you can add, delete and show (or list) objects, but some objects don't allow all of these or have some extra commands of their own. The help command works for all objects and prints out a list of the available commands and the argument syntax conventions ๐Ÿ“–

If you don't give a command, a default one gets assumed. Usually that's list, or help if the objects of that class can't be listed ๐Ÿซถ

๐ŸŒˆ ENVIRONMENT ๐ŸŒˆ

  • COLORFGBG โ€” If it's set, its value is used to figure out whether the background is dark or light, and then contrast colors get used. The COLORFGBG environment variable usually has either two or three values separated by semicolons, and we only care about the last value. If that value is 0-6 or 8, colors suitable for a dark background get chosen ๐ŸŒ™

Here's a cute example:

COLORFGBG=";0" ip -c a

๐Ÿšฆ EXIT STATUS ๐Ÿšฆ

The exit status is 0 if the command worked โœ… It's 1 if there's a syntax error ๐Ÿ™…โ€โ™€๏ธ If the kernel reported an error, the exit status is 2 ๐Ÿ’€

๐Ÿ“ EXAMPLES ๐Ÿ“

  • ip addr โ€” Shows the addresses assigned to all network interfaces ๐Ÿก
  • ip neigh โ€” Shows the current neighbour table in the kernel ๐Ÿ‘ฏ
  • ip link set x up โ€” Brings up interface x ๐ŸŸข
  • ip link set x down โ€” Brings down interface x ๐Ÿ”ด
  • ip route โ€” Shows the table routes ๐Ÿ—บ๏ธ

๐Ÿ“œ HISTORY ๐Ÿ“œ

ip was written by Alexey N. Kuznetsov and added in Linux 2.2. Legend behavior fr ๐Ÿ‘‘

๐Ÿ”— SEE ALSO ๐Ÿ”—

Here's where to go for more: ip-address(8), ip-addrlabel(8), ip-fou(8), ip-ioam(8), ip-l2tp(8), ip-link(8), ip-macsec(8), ip-maddress(8), ip-monitor(8), ip-mptcp(8), ip-mroute(8), ip-neighbour(8), ip-netconf(8), ip-netns(8), ip-nexthop(8), ip-ntable(8), ip-route(8), ip-rule(8), ip-sr(8), ip-stats(8), ip-tcp_metrics(8), ip-token(8), ip-tunnel(8), ip-vrf(8), ip-xfrm(8), and the IP Command reference ip-cref.ps ๐Ÿ“š

๐Ÿ› REPORTING BUGS ๐Ÿ›

If you find a bug, report it to the Network Developers mailing list at netdev@vger.kernel.org. That's where the development and maintenance is mainly done ๐Ÿ’Œ You don't have to be subscribed to the list to send a message there, so no excuses ๐Ÿ™ˆ

๐Ÿ‘ฉโ€๐Ÿ’ป AUTHOR ๐Ÿ‘ฉโ€๐Ÿ’ป

Original Manpage by Michail Litvak <mci@owl.openwall.com> ๐Ÿซถ


Okay bestie that's the whole tea โ˜•๐Ÿ’– iproute2 ยท 20 Dec 2011 ยท IP(8) โ€” periodt ๐Ÿ’…โœจ