ubuntu server设置静态IP和DNS

设置IP:

vim /etc/network/interfaces

将以下内容:

auto eth0
iface eth0 inet dhcp

修改为:

auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx

把xxx.xxx.xxx设置为你要个性的信息既可,其中
auto eth0  #开机自动连接网络
iface eth0 inet static   #static表示使用固定ipdhcp表述使用动态ip
address 是本机IP地址
netmask 子网掩码
gateway 网关

如果使用nano编辑的话
ctrl+o  #保存配置
ctrl+x  #退出

设置DNS

linux系统的DNS信息是保存在/etc/resolv.conf , 但是在ubuntu中用vim打开这个文件你会发现有如下文字的提示

DO NOT EDIT THIS FILE BY HAND — YOUR CHANGES WILL BE OVERWRITTEN

所以不能直接个性这个文件,这个内容可能会被覆盖

在ubuntu中dns信息是放在/etc/resolvconf/resolv.conf.d/目录下

一般情况下这个目录下有base和head两个文件夹

vim /etc/resolvconf/resolv.conf.d/base

nameserver 8.8.8.8
nameserver 114.114.114.114

保存后执行

resolvconf -u

用以下命令使网络设置生效

service networking restart
sudo /etc/init.d/networking restart

时间: 2024-08-08 11:48:22

ubuntu server设置静态IP和DNS的相关文章

[Ubuntu] 如何设置静态 IP 和 DNS

要设置 IP 和 DNS 解析服务器,编辑 /etc/network/interfaces: # interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 192.168.1.6 gateway 192.168.1.1 netmask 255.255.255.0 dns-nameservers 192.168.1.

Ubuntu中设置静态IP和DNS(转载)

原文地址:http://blog.sina.com.cn/s/blog_669421480102v3bb.html VMware 中使用网络,对虚拟机设置静态IP: 在Ubuntu中设置静态IP共两步:1>设置IP:2>设置DNS 1>设置IP    编辑 /etc/network/interface文件:       sudo vi /etc/network/interface auto eth0    iface eth0 inet static              //  指

转:ubuntu上设置静态ip

平台:ubuntu12.10 32/64bit (或者VM上安装的ubuntu12.10) 起因:工作需要,分配固定ip.小鸟不好意思问网管,按照以下步骤执行完毕即可,分为两个部分:图形界面修改 和 命令行下修改,任选其一即可 注意:1.本文修改固定IP的前提是:网线经路由器到PC 注意:2.VM上跑的系统必须使用在Setting里的Network选择桥链接 图形界面修改 1.打开ubuntu里的编辑连接(无线网络要编辑默认的链接) 2.修改IPv4的方法为“手动” 3.添加 [plain] v

CentOS7修改设置静态IP和DNS

当前位置: 主页 > CentOS入门 > 系统配置 > CentOS7修改设置静态IP和DNS 时间:2016-02-22 00:55来源:blog.csdn.net 作者:get_set的专栏 举报 点击:4048次 最近因为学习Puppet,用虚拟机装了个CentOS,使用的NAT的网络模式,为了防止再次启动系统的时候网络IP发生变化,因此设置静态IP和DNS. 由于CentOS是最小化安装,没有ifconfig命令,因此可以采用ip命令查看. 查看IP分配情况: # ip add

CentOS7 修改设置静态IP和DNS

最近因为学习Puppet,用虚拟机装了个CentOS,使用的NAT的网络模式,为了防止再次启动系统的时候网络IP发生变化,因此设置静态IP和DNS. 由于CentOS是最小化安装,没有ifconfig命令,因此可以采用ip命令查看. 查看IP分配情况: # ip addr 发现里边只有一个LOOPBACK的127.0.0.1的回环地址,原来CentOS刚安装后默认是不启动网络连接的. 设置IP和DNS主要在下面的配置文件中修改: # vi /etc/sysconfig/network-scrip

Ubuntu设置静态IP以及DNS

Introduce 安装虚拟机无法DHCP获取地址,搜了点资料设置成功,记下来以后好找文档. 设置静态IP vi /etc/network/interfaces # The primary network interface auto eth0 #表示让网卡开机自动挂载eth0 iface eth0 inet static address 192.168.2.1 gateway 192.168.2.254 netmask 255.255.255.0 /etc/init.d/networking

Ubuntu 16设置固定IP和DNS

ubuntu 16  设置固定ip地址和dns 1.设置ip地址 vi /etc/network/interfaces 添加如下内容: # The primary network interface # ens160是网卡,不知道自己是什么样的网卡,可以通过命令ip addr查看auto ens160iface ens160 inet static # 设置固定的ip地址,如下示例address 10.0.0.2 # 子网和网关可以通过route -n查看netmask 255.255.255.

Centos6.2设置静态ip和dns

参考了如下文章:https://gist.github.com/fernandoaleman/2172388http://www.lifelinux.com/how-to-configure-static-ip-address-on-centos/http://www.ehowstuff.com/how-to-configure-static-ip-address-on-centos-6-2-linux-server/http://www.liurongxing.com/centos-dns-i

Ubuntu server中静态IP配置

(1)修改IP 配置文件 /etc/network/interfaces 加入以下语句:auto eth0iface eth0 inet staticaddress 192.168.2.86 #IP地址netmask 255.255.255.0 #子网掩码gateway 192.168.2.1 #网关 (2)修改DNS 配置文件 /etc/resolv.conf 加入以下语句:nameserver 192.168.2.1 #希望修改成的DNS nameserver 8.8.8.8 这里有点有问题