上次装了一个Ubuntu14.04 server服务器,由于IP没有进行设置(默认为自动分配IP),重启后,IP经常自动变化,所以后面进行了静态IP的设置,才能使得服务器IP地址固定
下面讲讲静态IP设置的大体步骤(这里ip默认网关为192.168.13.1):
一、通过如下命令查看IP的设置情况
1、静态IP配置:vim /etc/network/interfaces
默认显示如下(dhcp分配):
#The loopback network interface
auto lo
iface lo inet loopback
#The Primary network interface
auto p2p1
iface p2p1 inet dhcp
改为固定静态ip:
#The loopback network interface
auto lo
iface lo inet loopback
#The Primary network interface
auto p2p1
#iface p2p1 inet dhcp
iface p2p1 inet static
address 192.168.13.110 //ip地址
netmask 255.255.255.0 //子网掩码
network 192.168.13.0
broadcast 192.168.13.255
gateway 192.168.13.1 //网关
dns-nameservers 192.168.13.1
2、手动设置DNS服务器:vim /etc/resolv.conf
注释掉之前的nameserver
末尾加上
nameserver 192.168.13.1
3、重启network server
/etc/init.d/networking restart
注:如果需要永久性更改DNS,则需要修改如下文件
vim /etc/resolvconf/resolv.conf.d/base