Debian系統使用/etc/network/interfaces文件來配置網卡,通過修改這個文件可以實現IP地址的綁定,此文章主要介紹Debian系統綁定ipv4地址。
首先通過ssh登錄系統(root權限):
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 自動激活網卡,其中eth0代表網絡接口名稱。
iface eth0 inet static 表示靜態IP配置。
address 要分配的靜態IP地址。
netmask 子網掩碼。
gateway 默認網關。
保存后重啟網絡:
sudo /etc/init.d/networking restart 或 sudo service networking restart