1. 编辑/etc/network/interfaces
vim /etc/network/interfaces
2.将以下五项添加到/etc/network/interfaces中
- Static declaration (using <interface> chosen above): iface <interface> inet static
- Static IP address: address <chosen ip>
- Network gateway: gateway <gateway ip>
- Netmask / subnet: netmask <netmask ip>
- DNS nameservers: dns-nameservers <dns ip’s>
3. 修改后文件如下
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
# The primary network interface
iface eth0 inet static
address 192.168.1.8
gateway 192.168.1.1
netmask 255.255.255.0
dns-nameservers 223.5.5.5 223.6.6.6
4. 重启网络服务
service networking restart