1
1

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 1 year has passed since last update.

定時帰る術-Linuxネットワーク情報(ipコマンド)

Posted at

IP情報表示

川口がよくみるのは↓だけです
ip:NICのIPはなんだ(/XXも見るべき)、セカンダリIPが持っているか(IPアドレスが表示されてない場合もある、IPが設定されているか、NICがUPになっているかを確認した方がいい)
inet6:ipv6が有効されているのが
link/ether:MACアドレスはなんだ
MTU:mtuはなんだ

[root@test tmp]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:9d:99:92 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic noprefixroute enp0s3
       valid_lft 86399sec preferred_lft 86399sec
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:60:2e:b8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.102/24 brd 192.168.56.255 scope global dynamic noprefixroute enp0s8
       valid_lft 559sec preferred_lft 559sec
    inet6 fe80::a00:27ff:fe60:2eb8/64 scope link
       valid_lft forever preferred_lft forever

ARP情報表示

同セグの場合、pingがとれなかったら、必ずARPを確認する。FWで拒否されたのか、本当にとれないのかが確認できる。
(FWで拒否される場合、対象サーバのMACアドレスが↓に表示される)

[root@test tmp]# ip n
192.168.56.100 dev enp0s8 lladdr 08:00:27:f5:8d:95 STALE
10.0.2.2 dev enp0s3 lladdr 52:54:00:12:35:02 REACHABLE
192.168.56.1 dev enp0s8 lladdr 0a:00:27:00:00:07 DELAY

ルーティング情報表示

NWトラブルシューティングする場合、よく使う

[root@test tmp]# ip r
default via 10.0.2.2 dev enp0s3 proto dhcp metric 102
1.1.1.0/24 via 1.1.1.254 dev enp0s3 proto static metric 102
1.1.1.254 dev enp0s3 proto static scope link metric 102
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 metric 102
192.168.56.0/24 dev enp0s8 proto kernel scope link src 192.168.56.102 metric 101

個人的には↑を目で見るのがめんどくさいし、定時帰られなくなるため、↓もよく使う
8.8.8.8に行くのルーティングを表示される

[root@test tmp]# ip route get 8.8.8.8
8.8.8.8 via 10.0.2.2 dev enp0s3 src 10.0.2.15 uid 0
    cache

ルーティング削除

[root@test tmp]# ip route del 1.1.1.0/24 via 1.1.1.254
[root@test tmp]# ip route
default via 10.0.2.2 dev enp0s3 proto dhcp metric 102
1.1.1.254 dev enp0s3 proto static scope link metric 102
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 metric 102
192.168.56.0/24 dev enp0s8 proto kernel scope link src 192.168.56.102 metric 101

ルーティング追加(metric指定)

[root@test tmp]# ip route add 1.1.1.0/24 via 1.1.1.254 metric 10
[root@test tmp]# ip route
default via 10.0.2.2 dev enp0s3 proto dhcp metric 102
1.1.1.0/24 via 1.1.1.254 dev enp0s3 metric 10
1.1.1.254 dev enp0s3 proto static scope link metric 102
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 metric 102
192.168.56.0/24 dev enp0s8 proto kernel scope link src 192.168.56.102 metric 1
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?