ip

ネットワーク

書き方

ip <object> <command>

Linux で住所・経路・近隣表をすべて扱う一つの命令で、ifconfig と route と arp を置き換えます。ここで変えたものは再起動で消えるため、残すには網の設定ファイルにも書きます。

よく使うオプション

オプション意味
a / addr showInterfaces and their addresses. Replaces ifconfig.
r / routeThe routing table. Replaces route.
neighThe ARP/neighbour table. Replaces arp.
link set eth0 up|downBring an interface up or down.
-brOne short line per entry, far easier to read.
route get <ip>Which interface and source address would be used for that destination.
-4 / -6Restrict the output to one address family.

ip -br a

Every interface, state and address in a compact table.

ip route get 8.8.8.8

Which route and source IP the kernel would pick.

sudo ip addr add 192.168.1.50/24 dev eth0

Add an address, live and temporary.

つながらないとき、どこまで行けたのかを絞ります — 名前が引けないのか、経路がないのか、ポートが閉じているのか。

読み方

  • 角括弧 [ ] は省いてよい部分です。
  • 三点 … は複数並べられるという意味です。
  • オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。

よくある質問

Q. ip は何をしますか。

Linux で住所・経路・近隣表をすべて扱う一つの命令で、ifconfig と route と arp を置き換えます。ここで変えたものは再起動で消えるため、残すには網の設定ファイルにも書きます。

Q. どう打ちますか。

ip <object> <command> — 角括弧は省いてよい部分です。

Q. よく使うオプションはいくつですか。

ここにまとめたのは7個です。全部は man ip にあります。このコマンドはネットワークの仲間です。

関連するコマンド

man ページ: man ip