标签:
给192.168.1.244设定为固定Ip
1.找到文件并作如下修改:
vim /etc/network/interfaces
修改结果为如下部分:
# 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
# The primary network interface
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
标签:
原文地址:http://my.oschina.net/u/2338362/blog/396922