`

Ubuntu下静态配置IP

 
阅读更多

ubuntu默认的使用DHCP分配IP,现需要给ubuntu静态分配IP地址

1、ctrl+alt + t快捷键打开 终端 输入 sudo vim /etc/network/interfaces

输入如下内容:

auto lo
auto eth0
iface lo inet loopback
iface eth0 inet static
address 192.168.1.125
gateway 192.168.1.7
netmask 255.255.255.0

 address 192.168.1.125:表示你的局域网IP

 

 gateway 192.168.1.7:表示你的网关地址

 netmask 255.255.255.0:表示 你的子网掩码

2、修改DNS服务器的地址 sudo vim /etc/resolv.conf 添加如下内容:

nameserver 192.168.1.7//你的DNS服务器地址
nameserver 8.8.8.8       //默认的DNS服务器地址

3、sudo /etc/init.d/networking restart

     或ifup eth0 

4、生成永久DNS配置 

     cd /etc/resolveconf/resolv.conf.d

     vim base

     添加: name

     nameserver 192.168.1.7

     nameserver 8.8.8.8    
保存退出

这样配置的IP就永久生效了。

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics