LoginSignup
3
2

More than 1 year has passed since last update.

ipコマンド クイックリファレンス

Last updated at Posted at 2022-01-28

概要

ときどき忘れてしまうので、ipコマンドの主なサブコマンドの書式をメモ🖋
対象のサブコマンドは以下。

サブコマンド 機能    
ip-address IPアドレスの管理
ip-link ネットワークデバイスのコンフィグレーション
ip-monitor ネットワークの状態監視
ip-neighbour neighbour/arp テーブルの管理
ip-netns ネットワークネームスペースの管理
ip-route ルーティングテーブルの管理

ip-address コマンド

ip address add

eth0に対してIPv4アドレス192.168.1.1/24を追加する。

# ip address add 192.168.1.1/24 dev eth0 

eth0に対してIPv6アドレスfc00::1234/64を追加する。

# ip address add fc00::1234/64 dev eth0 

ip address del

eth0からIPv4アドレス192.168.1.1/24を削除する。

# ip address del 192.168.1.1/24 dev eth0

ip address del

eth0からIPv6アドレスfc00::1234/64を削除する。

# ip address del fc00::1234/64 dev eth0

ip address show

全てのNICの情報を表示する

# ip addr show

eth0の情報を表示する

# ip addr show eth0

ip-link コマンド

ip link set

eth0のMTUを8000バイトに変更する

# ip link set eth0 mtu 8000

eth0をアップする。

# ip link set eth0 up

eth0をダウンする。

# ip link set eth0 down

eth0をプロミスキャスモードに設定する。

# ip link set eth0 promisc on

eth0のプロミスキャスモードを解除する。

# ip link set eth0 promisc off

veth0にネームスペースNSに割り当てる。

ip link set veth0 netns NS

ip link add

仮想ブリッジbr0を作成する。

# ip link add br0 type bridge

eth0上にVLAN ID 100を指定してタグVLANインタフェースeth0.100を作成する。

# ip link add link eth0 name eth0.100 type vlan id 100

仮想イーサネットピア veth0 veth1 を作成する。

# ip link add veth0 type veth peer name veth1

ip link delete

仮想ブリッジbr0を削除する。

# ip link add br0 type bridge

eth0からタグVLANインタフェースeth0.100を削除する。

# ip link delete link eth0 name eth0.100 type vlan

仮想イーサネットピア veth0 veth1 を削除する。

# ip link delete veth0 type veth peer name veth1

ip-monitor コマンド

短形式のタイムスタンプ付きで全てのイベントをモニターする。

# ip -ts monitor all

ip-neighbour コマンド

ip neigh show

neighbourテーブルを表示する。

# ip neigh show

ip neigh add

eth0にARPエントリー192.168.1.10/01:23:45:67:89:abを追加する。

# ip neigh add 192.168.1.10 lladdr 01:23:45:67:89:ab dev  eth0

ip neigh del

eth0から192.168.1.10のARPエントリーを削除する。

# ip neigh del 192.168.1.10 dev eth0

ip-netns コマンド

ip netns

ネームスペースの一覧を表示する。

# ip netns

ip netns add

ネームスペースNSを追加する。

# ip netns add NS

ip netns exec

ネームスペースNSにおいてip addr コマンドを実行する。

# ip netns exec NS ip addr

ip netns del

ネームスペースNSを削除する。

# ip netns del NS

ip-route コマンド

ip route show

経路情報を表示する。

# ip route show

ip route add

IPv4ネットワーク192.168.101.0/24宛の経路としてゲートウェイ192.168.100.254を設定する。

# ip route add 192.168.101.0/24 via 192.168.100.254

IPv6ネットワークfc00:1000::/64宛の経路としてゲートウェイfc00::1を設定する。

# ip route add fc00:1000::/64 via fc00::1

ip route del

IPv4ネットワーク192.168.101.0/24宛の経路を削除する。

# ip route del 192.168.101.0/24

IPv6ネットワークfc00:1000::/64宛の経路を削除する。

# ip route del fc00:1000::/64

ip route get

IPv4アドレス192.168.101.1宛の経路情報を表示する。

# ip route get 192.168.101.1

IPv6アドレスfc00:1000::123/64宛の経路情報を表示する。

# ip route get fc00:1000::123/64

ip route flush

eth0の経路情報をフラッシュする。

# ip route flush dev eth0
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2