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

Ubuntu设置静态IP以及DNS

2018-03-30 16:56 337 查看

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 restart
or
service networking restart
# Centos**
vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=none
HWADDR=00:0C:29:1D:86:BD
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Ethernet
UUID=da0d1da0-568a-45cf-a93f-66a30a4870e7
IPADDR=192.168.1.12
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
IPV6INIT=no
USERCTL=no

设置DNS

vi  /etc/resolvconf/resolv.conf.d/base
#添加
nameserver 8.8.8.8
nameserver 8.8.4.4

resolvconf -u
# Centos
vi /etc/resolv.conf

nameserver 168.95.1.1
nameserver 8.8.8.8
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux 设置 静态