Ubuntu12.04配置永久静态ip地址

1 切换到 root 用户

先临时切换到root用户(由于我不想每打一个命令都要在前面加上sudo)ubuntu

$ sudo -i

而后,输入密码临时切换到root用户.以下图:
vim

2 配置IP

打开 /etc/network/interfaces 同时配置如下内容服务器

# vim /etc/network/interfaces


具体的地址能够根据本身的状况来配置
gateway 即网关地址,我写的是我路由器的地址
重新启动网络:网络

# /etc/init.d/networking restart

3 配置DNS服务器

# vim  /etc/resolv.conf


由于写在 /etc/resolv.conf 下面的内容会被覆盖,因此须要将DNS写在其余地方 ,
须要将DNS写在 /etc/resolvconf/resolv.conf.d/base3d

3.1 安装 resolvconf

# apt-get install resolvconf

3.2 写入DNS

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

Ubuntu18.04 须要写入 /etc/resolvconf/resolv.conf.d/head 才有效
而后写入DNS好比,写入下面两条:rest

nameserver 114.114.114.114
nameserver 8.8.8.8

4 使配置生效,重启Ubuntu12.04

# rebootcode

相关文章
相关标签/搜索