参考
- Network Configuration (日本語) - ArchWiki
- Linux Set Up Routing with ip Command
- iprouteパッケージに入っています。
よく使う
固定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
が出る場合
- 一度ネットワーク設定を飛ばせば解決した。"RTNETLINK answers: File exists"を解消する - R42日記
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 }