Debian系統(tǒng)使用/etc/network/interfaces文件來配置網(wǎng)卡,通過修改這個文件可以實現(xiàn)IP地址的綁定,此文章主要介紹Debian系統(tǒng)綁定ipv4地址。
首先通過ssh登錄系統(tǒng)(root權(quán)限):
sudo nano /etc/network/interfaces
寫入以下配置:
auto eth0 iface eth0 inet static address 192.168.1.2 netmask 255.255.255.0 gateway 192.168.1.1
其中含義:
auto eth0 自動激活網(wǎng)卡,其中eth0代表網(wǎng)絡(luò)接口名稱。
iface eth0 inet static 表示靜態(tài)IP配置。
address 要分配的靜態(tài)IP地址。
netmask 子網(wǎng)掩碼。
gateway 默認網(wǎng)關(guān)。
保存后重啟網(wǎng)絡(luò):
sudo /etc/init.d/networking restart 或 sudo service networking restart