Ubuntu网络配置IP和DNS等,适用于14.04,16.04和17.10
本文主要介绍Ubuntu系统的网络设置,包括IP,DNS和主机名等,适用于14.04,16.04和17.10等版本
=============== 完美的分割线 ================
======== 对于14.04和16.04版本 ========
Ubuntu 的网络配置文件主要有以下几种:IP地址配置文件、主机名称配置文件、DNS配置文件。
1.配置IP地址
1.1.配置动态IP地址
sudo vim /etc/network/interfaces
auto eth0
iface eth0 inet dhcp
重启网卡
sudo /etc/init.d/networking restart
也可以直接输入下面的命令来获取地址
sudo dhclient eth0
1.2.配置临时的静态IP地址
ifconfig ens33 192.168.1.65 netmask 255.255.255.0
route add default gw 192.168.1.1
1.3. 配置永久的静态IP地址
sudo vim /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.1.11
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 202.106.0.20
dns-nameservers 8.8.8.8
重启网卡
sudo /etc/init.d/networking restart
1.4. 附:添加第二个IP地址(虚拟IP地址)
sudo vim /etc/network/interfaces
auto eth0:
iface eth0: inet static
address 192.168.1.60
netmask 255.255.255.0
gateway x.x.x.x
network x.x.x.x
broadcast x.x.x.x
重启网卡:
sudo /etc/init.d/networking restart
2.修改主机名
查看当前主机名
sudo /bin/hostname
2.1.临时修改主机名
sudo /bin/hostname myhostxxx
2.2.永久修改主机名
vim /etc/hostname
3.修改DNS配置
3.1.配置hosts文件查询
修改/etc/hosts文件使用本机的静态查询.
sudo vim /etc/hosts
3.2.配置使用DNS服务器进行查询
sudo vim /etc/resolv.conf
nameserver 192.168.1.2
nameserver 202.106.0.20
nameserver 8.8.8.8
有时候需要修改下面的文件
sudo vim /etc/resolvconf/resolv.conf.d/base
重启网卡
sudo /etc/init.d/networking restart
======== 对于Ubuntu 17.10,18.04版本 ========
对于17.10版本,网络配置中IP和DNS的配置方法变化比较大
1.配置静态IP和DNS
1)可以使用ip add查看网卡名称
ip add
2)编辑网卡配置文件
sudo vim /etc/netplan/-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan().
network:
version:
renderer: networkd
ethernets:
ens33:
dhcp4: no #dhcp4关闭
dhcp6: no #dhcp6关闭
addresses: [192.168.1.65/]
gateway4: 192.168.1.1
nameservers:
addresses: [202.106.0.20,4.4.4.4]
通过改配置文件,可以设置IP,网关和DNS地址,
在/etc/resolv.conf中配置的DNS,网络重启后就会失效,可以不配置
3)执行以下命令让配置生效
netplan apply
2.主机名修改方法与之前版本的相同
======== 完毕,呵呵呵呵 ========
Ubuntu网络配置IP和DNS等,适用于14.04,16.04和17.10的更多相关文章
- ubuntu 命令配置ip 网关 dns
如果是在虚拟机中使用Ubuntu,先设置好主机的网络,然后配置虚拟机Ubuntu的IP和网关 如果主机操作系统就是Ubuntu,请直接参照下文进行设置 内容如下: 1. 检验是否可以连通,就使用pin ...
- ubuntu 虚拟机配置 IP、子网掩码、网关、DNS
ubuntu 虚拟机配置 IP.子网掩码.网关.DNS 执行 sudo vim /etc/network/interfaces 添加如下配置: auto eth0 iface eth0 inet st ...
- ubuntu网络配置相关知识(转载)
From:http://os.51cto.com/art/201003/188055.htm 文章主要介绍Ubuntu网络配置,希望能让Linux新手学习参考.更好使用Ubuntu.更有效的学习Ubu ...
- ubuntu网络配置命令
Ubuntu网络配置例如: (1) 配置eth0的IP地址, 同时激活该设备. #ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up (2) 配置e ...
- ubuntu 网络配置及ssh文件传输
一.ubuntu网路配置 参考http://www.cnblogs.com/rusty/archive/2011/04/06/2007139.html /etc/network/interfaces ...
- Desktop Ubuntu 14.04LTS/16.04科学计算环境配置
Desktop Ubuntu 14.04LTS/16.04科学计算环境配置 计算机硬件配置 cpu i5 6代 内存容量 8G gpu GTX960 显存容量 2G(建议显存在4G以上,否则一些稍具规 ...
- Ubuntu 14.04 16.04 Linux nvidia 驱动下载与安装
Ubuntu 14.04 16.04 nvidia 驱动安装 最简单直观的方式是在如下的对话框中直接选择驱动安装即可 但是有时候,驱动不够新,比如14.04用的是340.98版本,如果手动安装驱动可以 ...
- Ubuntu LTS 系统学习使用体会和实用工具软件汇总 6.04 8.04 10.04 12.04 14.04 16.04
Ubuntu LTS 系统学习体会和工具软件汇总 6.04 8.04 10.04 12.04 14.04 16.04 ubuntu入门必备pdf:http://download.csdn.net/de ...
- ubuntu网络配置
本文介绍ubuntu中的网络配置方法. ubuntu需要在/etc/network/interfaces文件中设置网络配置,基本的格式如下: auto <网卡名> iface <网卡 ...
随机推荐
- t分布, 卡方x分布,F分布
T分布:温良宽厚 本文由“医学统计分析精粹”小编“Hiu”原创完成,文章采用知识共享Attribution-NonCommercial-NoDerivatives 4.0国际许可协议(http://c ...
- poj1106 Transmitters
地址:http://poj.org/problem?id=1106 题目: Transmitters Time Limit: 1000MS Memory Limit: 10000K Total S ...
- zoj3820 树的直径+二分
这题是个遗憾 !!!!!当时一直不敢相信两个站一定在直径上,赛后想想自己真的是脑袋抽风, 如果其中一个站不在直径上就反向的说明了这条不是直径.可以很明白我们可以肯定的是有一个点一定在直径上假如另外一个 ...
- 2017-2018-1 JaWorld 团队作业--冲刺2
2017-2018-1 JaWorld 团队作业--冲刺2 (20162314) 总体架构 我们本次团队项目设定为基于Android系统Java架构下的打飞机小游戏 游戏中所有模型的原型设定是精灵,因 ...
- #ZLYD团队第二周项目总结
ZLYD团队第二周项目总结 项目进展 确定项目内容.目标.实现计划 首先确定游戏界面的游戏区域中墙的位置,绘制其图形,并通过其中的方法,返回墙壁的位置等属性. 根据豆子的位置,绘制其图形. 初始化吃豆 ...
- G-Sensor 8452驱动及相关
8452是一款G-Sensor芯片,采用I2C跟主芯片通讯,采用中断方式跟操作系统协作.通过内部检测XYZ三个方向的加速度,实现各种应用. (1)原理框图如下: 现在来实现在WINCE中的I2C驱动, ...
- 在Github上搭建博客
貌似还是这个链接最靠谱呀 http://my.oschina.net/nark/blog/116299 如何利用github建立个人博客:之一 在线编辑器http://markable.in/ed ...
- fiddler几种功能强大的用法(二)
参考网址:http://blog.rekfan.com/articles/228.html http://www.cnblogs.com/tugenhua0707/p/4637771.html htt ...
- HDU 1503 Advanced Fruits(LCS+记录路径)
http://acm.hdu.edu.cn/showproblem.php?pid=1503 题意: 给出两个串,现在要确定一个尽量短的串,使得该串的子串包含了题目所给的两个串. 思路: 这道题目就是 ...
- 2016湘潭邀请赛—Heartstone
http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1246 题意: 有n只怪,每只怪有指定的HP.现在1和2两种攻击方式,前者扣 ...