アプリケーション開発ポータルサイト
ServerNote.NET
カテゴリー【Debian
Debian 12で固定IPアドレスを使う設定をする
POSTED BY
2025-02-18

rootになってから行う。

sudo -s

net-toolsのインストール

apt install net-tools

現在の状況を確認する

ifconfig

nicの名称(eno1など)を確認して、

/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

# The primary network interface
allow-hotplug eno1
#iface eno1 inet dhcp
# This is an autoconfigured IPv6 interface
iface eno1 inet6 auto

iface eno1 inet static
address 192.168.1.94
network 192.168.1.0
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1

ネットワークカードがeno1、ゲートウェイ・ネームサーバが192.168.1.1、自分のIPを192.168.1.94とする設定。
さらに忘れず/etc/resolv.confを修正する。

nameserver 192.168.1.1

systemctlコマンドで反映する。SSH等接続は切れるので注意。

systemctl restart ifup@eno1

ちゃんと希望の設定になっているか確認。

ifconfig

※本記事は当サイト管理人の個人的な備忘録です。本記事の参照又は付随ソースコード利用後にいかなる損害が発生しても当サイト及び管理人は一切責任を負いません。
※本記事内容の無断転載を禁じます。
【WEBMASTER/管理人】
自営業プログラマーです。お仕事ください!
ご連絡は以下アドレスまでお願いします★

【キーワード検索】