デスクトップとして使っているDebian9のIPアドレス(ipv4)を自動取得をやめて固定にしました。その記録です。
最近のLINUXはほとんどデフォルトでデスクトップ用として使えるようになります。Debian9はちよっと日本語の設定でゴタゴタしましたが、ほぼ快適です。必要なソフトはaptから追加しますが、初設定はできるだけデフォルトのままにしています。市販のワイヤレスルーター(I/Oデータ11ac対応無線LANルーターWN-AC1167GR)に有線で接続ておいてインストールしましたから、DHCPを使うことになっています。
写真印刷のためにたまにWindowsも使うので、sambaでファイルサーバーとしているのですが、最近時々IPアドレスが変化していき、サーバーの指定が面倒になってきました。
そこで固定IPを設定することとします。
最近のDebianでは、NetworkManagerでアドレスを管理していて、固定アドレスを設定するにもGUIが使えます。今回は素直に従います。
以前、生徒用クライアントの設定をしたときにはNetworkManagerではホスト名をdhcp側から設定できないので削除して、普通のdhcpクライアントを入れて使っていました。ワイヤレス環境で移動しながら接続が変わる場合、そのたびにホスト名が変わるのは逆に困りますから、このようになっているのでしょう。しかし、40台の生徒用機にホスト名をそれぞれ設定するにはdhcpが使えるほうが良いのです。
ipv6,mac,uuidなど、大事を取って、一部xxxxxxに変えてあります。
「設定」と書かれている「GNOME コントロールセンター」から「Network」
右下の[⚙]歯車マーク
[有線]のページへ。ここで左側、上から4つ目のIPv4を選択
アドレスの「自動」を「手動」にして、アドレス、マスク、ゲートウェイを記入する。
[適用]を押して戻ったら、[オン]をクリックして一度オフにし、再度オンにもどすと設定したIPアドレスが有効になる。
設定はこれで終わりなのですが、どこが書き換えられているのか探ってみます。
findで10分以内に変更されたファイルを探します。
adachi@debian64:~$ find /etc -mmin -10 /etc find: ‘/etc/polkit-1/localauthority’: 許可がありません find: ‘/etc/ssl/private’: 許可がありません /etc/NetworkManager/system-connections /etc/NetworkManager/system-connections/Wired connection 1 find: ‘/etc/cups/ssl’: 許可がありません /etc/resolv.conf
3つ出てきます。
最後のresolv.confを見るとipv6にも影響があったのかもしれませんが、ipy6は自動に任せます。
adachi@debian64:~$ cat /etc/resolv.conf # Generated by NetworkManager search flets-east.jp iptvf.jp nameserver 2409:13:8a40:be00:225:xxxx:xxxx:xxxx
次にsystem-connectionsを見ます。これはフォルダで、中に「Wired connection 1」があります。
adachi@debian64:~$ ll /etc/NetworkManager/ 合計 28 -rw-r--r-- 1 root root 58 3月 18 2017 NetworkManager.conf drwxr-xr-x 2 root root 4096 3月 18 2017 VPN drwxr-xr-x 2 root root 4096 3月 18 2017 conf.d drwxr-xr-x 5 root root 4096 7月 4 12:59 dispatcher.d drwxr-xr-x 2 root root 4096 3月 18 2017 dnsmasq-shared.d drwxr-xr-x 2 root root 4096 3月 18 2017 dnsmasq.d drwxr-xr-x 2 root root 4096 10月 30 10:06 system-connections adachi@debian64:~$ ll /etc/NetworkManager/system-connections/ 合計 4 -rw------- 1 root root 297 10月 30 10:06 Wired connection 1
Wired connection 1 の内容です。
root@debian64:~# cat /etc/NetworkManager/system-connections/Wired\ connection\ 1 [connection] id=Wired connection 1 uuid=43ef519a-757d-4f02-a6ae-xxxxxxxxxxxx type=ethernet permissions= timestamp=1540861413 [ethernet] mac-address-blacklist= [ipv4] address1=192.168.1.30/24,192.168.1.1 dns-search= method=manual [ipv6] addr-gen-mode=eui64 dns-search= ip6-privacy=2 method=auto
別のサーバーで、Squeezeのときだが、NetworkManagerを排除したときには /etc/network/interfaces で設定した。LINUXでは伝統的な方法。
root@solomon:~# cat /etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface #allow-hotplug eth0 #iface eth0 inet dhcp auto eth0 iface eth0 inet static address 192.168.1.6 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.2.255 gateway 192.168.1.3
現在のDebian9では、自動に任せており、ループバックの設定のみになっています。
adachi@debian64:~$ cat /etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback adachi@debian64:~$ ll /etc/network/interfaces.d 合計 0