- 打开网络配置文件
sudo gedit /etc/network/interfaces
- 输入以下配置进行静态IP的修改
# The primary network interface
auto eth0 #表示让网卡开机自动挂载eth0
iface eth0 inet static
address 192.168.2.1
gateway 192.168.2.254
netmask 255.255.255.0
#network 192.168.2.0
#broadcast 192.168.2.255
保存
3. 输入以下命令进行网络的重新启动
sudo /etc/init.d/networking restart