LoginSignup
1
1

More than 3 years have passed since last update.

Ubuntu core 20.04 NIC eth0 unmanaged

Posted at

はじめに

本資料は可能な限り正しく動作するものを記載していますが、内容に間違いがあった場合はコメントにてお知らせいただけると幸いです。

また、本資料は忘れやすい筆者の備忘録として書いているので読みづらい部分が在るかもしれませんがご了承ください

tl;dl

やったこと
- sudo vim /etc/netplan/50-cloud-init.yaml に対し renderer: NetworkManager を追加

環境

現在の状態

事前にやったこと

  • (1) SSHやPKGインストールの為にアドレスを振る
  • (2) 外部NWとの通信のためにdefaultGW設定
  • (3) dnsの設定
  • (4) NetworkManager はインストールされていなかったので、インストール実施
  • (5) システムアップデート
  1. ip addr change "192.168.xxx.xxx/24" dev eth0
  2. ip route change default via 192.168.xxx.254
  3. echo "nameserver 8.8.8.8" >> resolv.conf
  4. sudo apt install network-manager
  5. sudo apt update; sudo apt upgrade

ここから本題

下記の様になっておりPiを再起動すると ip コマンドで設定したアドレスや、ルーティングテーブルが消える。

ubuntu@ubuntu:~$ nmcli dev
DEVICE         TYPE      STATE         CONNECTION 
wlan0          wifi      disconnected  --         
eth0           ethernet  unmanaged     --         
lo             loopback  unmanaged     --         
p2p-dev-wlan0  wifi-p2p  unmanaged     --         
ubuntu@ubuntu:~$ 

やったこと

  • sudo vim /etc/netplan/50-cloud-init.yaml に対し renderer: NetworkManager を追加
    これでNIC管理がNetworkManagerに移譲された(?)
変更前
network:
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    version: 2
変更後
network:
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    version: 2
    renderer: NetworkManager
  • 変更後は sudo reboot で再起動
ubuntu@ubuntu:~$ nmcli dev
DEVICE         TYPE      STATE         CONNECTION 
wlan0          wifi      disconnected  --         
p2p-dev-wlan0  wifi-p2p  disconnected  --         
eth0           ethernet  connected     --         
lo             loopback  unmanaged     --         
ubuntu@ubuntu:~$ 
  • アドレスの設定はnmtuiを使った。

    設定方法については いつもの NetworkManager なので割愛

  • 最終的にこうなればOK

ubuntu@ubuntu:~$ nmcli dev
DEVICE         TYPE      STATE         CONNECTION
eth0           ethernet  connected     eth0
wlan0          wifi      disconnected  --
p2p-dev-wlan0  wifi-p2p  disconnected  --
lo             loopback  unmanaged     --
ubuntu@ubuntu:~$

image.png

  • 一応、外部に向けてPingやって返ってくるか試験
ubuntu@ubuntu:~$ ping 8.8.8.8 -c 3
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=116 time=40.8 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=116 time=49.8 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=116 time=32.7 ms

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 32.717/41.105/49.783/6.970 ms
ubuntu@ubuntu:~$
ubuntu@ubuntu:~$ ping google.com -c 3
PING google.com (172.217.26.110) 56(84) bytes of data.
64 bytes from kix05s01-in-f110.1e100.net (172.217.26.110): icmp_seq=1 ttl=57 time=27.3 ms
64 bytes from kix05s01-in-f110.1e100.net (172.217.26.110): icmp_seq=2 ttl=57 time=26.0 ms
64 bytes from kix05s01-in-f110.1e100.net (172.217.26.110): icmp_seq=3 ttl=57 time=24.8 ms

--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 24.817/26.036/27.286/1.008 ms
ubuntu@ubuntu:~$

- DNSはNetworkManagerで変えてるけど/etc/resolv.confみたら変わってない。これでいいのかな...

/etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0 trust-ad

  • nslookupとかdighostで調べてもちゃんと名前解決してるのでヨシとする。
ubuntu@ubuntu:~$ nslookup google.com
Server:         127.0.0.53
Address:        127.0.0.53#53

Non-authoritative answer:
Name:   google.com
Address: 172.217.26.110
Name:   google.com
Address: 2404:6800:400a:806::200e

ubuntu@ubuntu:~$

さいごに

1行入れて再起動しただけでいつもの設定方法でアドレス固定できたのは驚きだった。
カーネルいじるときみたいな変な神経使わないし、もうちょっと早くに知りたかった。。。

そしてなにげに時間かかったのが、Ubuntuの初期パスワードってなにーー!?ってこと
user=ubuntu
pass=ubuntu

へぇ、admin/adminとか、Ubuntu SSOとかじゃないんだね

Refs

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