给192.168.1.244设定为固定Ipvim
1.找到文件并做以下修改:服务器
vim /etc/network/interfacesoop
修改结果为以下部分:spa
# This file describes the network interfaces available on your systemrest
# and how to activate them. For more information, see interfaces(5).orm
# The loopback network interfaceserver
auto lodns
iface lo inet loopbackip
# The primary network interfaceit
auto p2p1
iface p2p1 inet static
address 192.168.1.244
gateway 192.168.1.1
netmask 255.255.255.0
注:p2p1为192.168.1.244网卡名,不一样服务器网卡名不一样,请自行修改
2. 修改dns解析
由于之前是dhcp解析,因此会自动分配dns服务器地址
而一旦设置为静态ip后就没有自动获取到的dns服务器了
要本身设置一个
vim /etc/resolv.conf
nameserver 202.96.128.86
nameserver 192.168.1.1
nameserver 220.170.64.68
3.改完上面,若是重启的话,仍是会变为原来的样子,因此要让其永久改变,所以,执行:
vim /etc/resolvconf/resolv.conf.d/base
nameserver 192.168.1.1
nameserver 220.170.64.68
3. 重启网卡:
/etc/init.d/networking restart