87
88

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ipコマンド

Last updated at Posted at 2013-08-23

参考

よく使う

固定IP
ip addr add 10.0.2.15/24 dev eth0
デフォルトゲートウェイ
ip route add default via 10.0.2.2
ルーティング確認
route -n

RTNETLINK answers: File existsが出る場合

ip addr flush dev eth0

ルーティング追加

ルーティング追加
ip route add 210.210.210.222 dev eth0

IP表示

IP表示
ip -f inet addr

出力例

1.ipアドレス表示

# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:1c:cf:2b brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
    inet6 fe80::a00:27ff:fe1c:cf2b/64 scope link 
       valid_lft forever preferred_lft forever
# ip link show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 08:00:27:1c:cf:2b brd ff:ff:ff:ff:ff:ff

2. 1の情報少ない版

# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 08:00:27:1c:cf:2b brd ff:ff:ff:ff:ff:ff

3.ARPテーブル表示

# ip neigh
10.0.2.2 dev eth0 lladdr 52:54:10:12:45:02 REACHABLE

4.ルーティング表示

# ip route
default via 10.0.2.2 dev eth0 
10.0.2.0/24 dev eth0  proto kernel  scope link  src 10.0.2.15

5.コネクション先の履歴?

# ip tcp_metrics | sort | more
207.200.74.27 age 2630.104sec rtt 99500us rttvar 93000us cwnd 10
...

6.ARPテーブルのモニタリング?

# ip monitor

7.help

helpをつけるとコマンドのオプションが表示されます。

$ ip link help
Usage: ip link add [link DEV] [ name ] NAME
                   [ txqueuelen PACKETS ]
                   [ address LLADDR ]
                   [ broadcast LLADDR ]
                   [ mtu MTU ]
                   [ numtxqueues QUEUE_COUNT ]
                   [ numrxqueues QUEUE_COUNT ]
                   type TYPE [ ARGS ]
       ip link delete DEV type TYPE [ ARGS ]

       ip link set { dev DEVICE | group DEVGROUP } [ { up | down } ]
	                  [ arp { on | off } ]
	                  [ dynamic { on | off } ]
	                  [ multicast { on | off } ]
	                  [ allmulticast { on | off } ]
	                  [ promisc { on | off } ]
	                  [ trailers { on | off } ]
	                  [ txqueuelen PACKETS ]
	                  [ name NEWNAME ]
	                  [ address LLADDR ]
	                  [ broadcast LLADDR ]
	                  [ mtu MTU ]
	                  [ netns PID ]
	                  [ netns NAME ]
			  [ alias NAME ]
	                  [ vf NUM [ mac LLADDR ]
				   [ vlan VLANID [ qos VLAN-QOS ] ]
				   [ rate TXRATE ] ] 
				   [ spoofchk { on | off} ] ] 
			  [ master DEVICE ]
			  [ nomaster ]
       ip link show [ DEVICE | group GROUP ]

TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | can | bridge | ipoib }
87
88
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
87
88

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?