Debian 11 dhcp は複数のインターフェイスに IP を割り当てます。

Debian 11 dhcp は複数のインターフェイスに IP を割り当てます。

光ファイバーに接続されている複数のインターフェース(eth0やensp1など)を持つサーバーがあります。これらの2つの接続は、このシステムが複数のタスクで使用され、リモートであるため、1つのインターフェイスを物理的に切断できないために必要です。

Debian 11をインストールしようとしましたが、インストール中に手動でeth0にIPアドレスを提供しようとすると、他のインターフェイスが異なるIPアドレスを取得することがわかりました。また、システムを再起動すると、eth0のIPアドレスが変更されます。

update-rc.d -f dhcp アンインストールしようとしましたが、目標を達成できませんでした。

ベストアンサー1

構成する必要があります。/etc/network/interfaces

構成例:

# for loopback
auto lo
iface lo inet loopback

# dhcp for eth0
auto eth0
allow-hotplug eth0
iface eth0 inet dhcp

# you can do the same for ensp1
auto ensp1
allow-hotplug ensp1
iface ensp1 inet dhcp

# manual ip for eth0
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.0.100
netmask 255.255.255.0

# YOU CAN ADD MORE IP'S TO THE INTERFACES WITH eth0:0, eth0:1 eth0:2, etc..
# more than one ip for eth0
auto eth0:0
allow-hotplug eth0:0
iface eth0:0 inet static
address 10.0.0.100
netmask 255.255.0.0

# You can do the same for ensp1
auto ensp1
allow-hotplug ensp1
iface ensp1 inet static
address 192.178.178.10
netmask 255.255.255.0

# You can do the same for ensp1:0
auto ensp1:0
allow-hotplug ensp1:0
iface ensp1:0 inet static
address 10.10.10.10
netmask 255.255.0.0

1台のマシンでは、1つのインターフェイスにDHCPと3つの静的IPを使用します。

# You can add also a nameserver for eth0, ensp1:0, etc..,
# but i prefer the nameserver in /etc/resolve.conf

auto ensp1:0
allow-hotplug ensp1:0
iface ensp1:0 inet static
address 10.10.10.10
netmask 255.255.0.0
dns-nameserver 10.10.x.x
dns-nameservers 8.8.8.8
nameserver x.x.x.x

nameserver編集のために/etc/resolve.conf

nameserver 192.168.x.x # local `
nameserver 8.8.8.8     # google 
nameserver x.x.x.x     # whatever`

(DNS) ネームサーバー定義、resolv.conf 構成ファイル

インターフェイスファイルで解決オプションを変更した後にresolv.confを更新する方法は?

編集後に再起動し、ネットワークの状態を確認できます。

systemctl restart networking

または

systemctl restart networking.service

または

/etc/init.d/networking restart

状態

systemctl status networking.service

/etc/netwotk/interfacesあなたのニーズに最適

必要な人はこの投稿を読んでくださいインターフェイスの追加情報:

ネットワークデバイス/インターフェース情報

Debian ネットワーク構成の確認:

Debian ネットワークの設定

おすすめ記事