LoginSignup
3
1

More than 1 year has passed since last update.

'Network is unreachable'からの'unknown connection'の罠 --20年(?)ぶりにLinuxをいじってみる08

Last updated at Posted at 2023-01-18

全8回の8 → 1|2|3|4|5|6|7|8

マザーボードを別のケースに移して再起動したらネットワークに繋がらなくなった件。

# ping -c 3 192.168.10.10
ping: connect: Network is unreachable

筐体を入れ替えただけなのに(マザボは同じなのに)繋がらないとはどういうわけか。
まずはこの辺を参考にして

# nmcli device status
DEVICE  TYPE      STATE         CONNECTION
enp2s0  ethernet  disconnected  --
lo      loopback  unmanaged     --

となっていたので

# nmcli connection up enp2s0
Error: unknown connection 'enp2s0'

もう頭の中から「?」しか飛び出さないわけだが、改めてググったところこんなページがヒット。

# ip a
...
2: enp2s0: <BROADCAST,MULICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel statu UP grouop default qlen 1000
    link/ether e0:cb:4e:d8:d9:9e brd ff:ff:ff:ff:ff:ff

となるのだが一方で

# nmcli connection show
NAME    UUID                                  TYPE      DEVICE
enp3s0  0c199785-43d9-3db1-8f86-81165e2c5648  ethernet  --

となってenp2s0enp3s0の違いが見つかる。もう少し詳しく書くと、DEVICEのところには本来ip aで出てくるデバイスが表示されなければいけないということで、nmcliで扱うのがconnection、ip aで出てくるのがDEVICEなのだそうだ。で、今はDEVICEがダウンしているため--になっていると。となれば強制的にenp3s0のほうでコネクションを有効化できないのかと思い試してみる。

# nmcli connection up enp3s0
Error: Connection activation failed: No suitable device found for this connection (device enp2s0 not available because profile is not compatible with device (mismatching interface name)).

…うーむ、名前が違うと言われたぞ。
と上のページの説明を読み進めたところ、connectionupするのでなく、disconnectedとなっているdeviceconnectするのでは? というのに思い当たる。

# nmcli device connect enp2s0
Device 'enp2s0' successfully activated with '6d97a1b9-9ff4-4bce-8d6a-e2ca676672f2'.

行けたのかもしれない。

# nmcli device status
DEVICE  TYPE      STATE      CONNECTION
enp2s0  ethernet  connected  enp2s0
lo      loopback  unmanaged  --

おぉ~。

# ip a
...
2: enp2s0: <BROADCAST,MULICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel statu UP grouop default qlen 1000
    link/ether e0:cb:4e:d8:d9:9e brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.5/24 brd 192.168.10.255 scope global dynamic noprefixroute enp2s0
...

おおぉ~。
ただこれだとIPアドレスがDHCPからの自動取得になっている。
IPアドレスの固定は前にやったし、これだけだとデフォルトゲートウェイが変わってないので、合わせて直す。

# nmcli connection modify enp2s0 ipv4.method manual ipv4.addresses "192.168.10.1/24"
# nmcli connection modify enp2s0 ipv4.gateway "192.168.10.10"
# systemctl restart NetworkService

からの

# ping -c 3 192.168.10.10
PING 192.168.10.10 (192.168.10.10) 56(04) bytes of data.
64 bytes from 192.168.10.10: icmp_seq=1 ttl=64 time=1.05 ms
64 bytes from 192.168.10.10: icmp_seq=1 ttl=64 time=1.08 ms
64 bytes from 192.168.10.10: icmp_seq=1 ttl=64 time=1.07 ms

--- 192.168.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 1.054/1.066/1.078/0.009 ms

長かった…。
それにしても、PCのガワを変えただけなのにネットワーク設定がなぜ変わったのかは謎。

3
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
3
1