ip
ネットワーク
書き方
ip <object> <command>Linux で住所・経路・近隣表をすべて扱う一つの命令で、ifconfig と route と arp を置き換えます。ここで変えたものは再起動で消えるため、残すには網の設定ファイルにも書きます。
よく使うオプション
| オプション | 意味 |
|---|---|
| a / addr show | Interfaces and their addresses. Replaces ifconfig. |
| r / route | The routing table. Replaces route. |
| neigh | The ARP/neighbour table. Replaces arp. |
| link set eth0 up|down | Bring an interface up or down. |
| -br | One short line per entry, far easier to read. |
| route get <ip> | Which interface and source address would be used for that destination. |
| -4 / -6 | Restrict the output to one address family. |
例
ip -br aEvery interface, state and address in a compact table.
ip route get 8.8.8.8Which route and source IP the kernel would pick.
sudo ip addr add 192.168.1.50/24 dev eth0Add an address, live and temporary.
つながらないとき、どこまで行けたのかを絞ります — 名前が引けないのか、経路がないのか、ポートが閉じているのか。
読み方
- 角括弧 [ ] は省いてよい部分です。
- 三点 … は複数並べられるという意味です。
- オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。
よくある質問
Q. ip は何をしますか。
Linux で住所・経路・近隣表をすべて扱う一つの命令で、ifconfig と route と arp を置き換えます。ここで変えたものは再起動で消えるため、残すには網の設定ファイルにも書きます。
Q. どう打ちますか。
ip <object> <command> — 角括弧は省いてよい部分です。
Q. よく使うオプションはいくつですか。
ここにまとめたのは7個です。全部は man ip にあります。このコマンドはネットワークの仲間です。
関連するコマンド
man ページ: man ip