Debian 11 / Linux如何快速設定固定IP

當安裝OS時大部人都是選用DHCP 方式來安裝,完成後有需要是就要改動IP連接方式,以下就是記錄Debian 11 如何設定固定IP方法‧

先用SSH 連到系統‧

先行備份
cp /etc/network/interfaces /root/

再檢查現時IP資訊
ip -c addr show

Debian 11 如何設定固定IP

修改 :
nano /etc/network/interfaces

Debian 11 改成以下內容

以下是我的網路IP.
# The loopback network interface
auto lo
iface lo inet loopback
 
# The primary network interface
auto eth0
iface eth0 inet static
 address 192.168.1.21
 netmask 255.255.255.0
 gateway 192.168.1.1
 dns-domain errorxyz.com
 dns-nameservers 192.168.1.1



如果是用HYPER-V 需要重閞
systemctl reboootsystemctl restart networking

這時ssh會斷開連接,因為IP已經改變了。 

參考 : NetworkConfiguration – Debian Wiki , 第 5 章 網絡設置 (debian.org)

發佈留言