您的位置:首页 > 运维架构 > Linux

linux 设置IP DNS 网关

2016-05-13 16:06 447 查看
一, 一次修改,重启后失败

设置IP

sudo ifconfig eth0 192.168.50.73 netmask 255.255.255.0

设置网关

sudo route add default gw 192.168.50.1

设置DNS

修改/etc/resolv.conf,在其中加入

nameserver DNS的地址1

nameserver DNS的地址2

二,永久修改

直接修改Ubuntu IP系统配置文件

Ubuntu IP的网络配置文件是根目录下:

sudo vi /etc/network/interfaces

# The primary network interface

auto eth0

iface eth0 inet static

address 192.168.50.73

gateway 192.168.50.1

netmask 255.255.255.0

重启

sudo /etc/init.d/networking restart

配置DNS

方法一、修改/etc/network/interfaces

dns-nameservers 8.8.8.8

方法二、修改/etc/resolvconf/resolv.conf.d/base文件,该文件默认是空的,在里面写入:

nameserver 8.8.8.8

修改完之后保存,然后执行resolvconf -u

重启电脑

reboot

查看 ifconfig
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: