ubuntu如何设置静态IP?

设置静态IP

1.编辑/etc/network/interfaces文件:

# This file describes the network interfaces available on your system

# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface

auto lo

iface lo inet loopback

# The primary network interface

auto eth0#etho为通常的Ubuntu的网关名称,有时也会改变,可通过ifconfig命令查看,有时会出现如ens160,ens33等名称

iface eth0 inet static#设置IP为静止IP,

address 192.168.1.103#你想设置的静态IP地址

netmask 255.255.255.0#子网掩码,通常为255.255.255.0

#network 192.168.1.0

broadcast 192.168.1.255 #广播地址,可以通过ifconfig查看现有的。,

gateway 192.168.1.8#网关, #netstat -r 命令或者   nm-tool   查看现有的

# dns-* options are implemented by the resolvconf package, if installed

dns-nameservers 61.139.2.69#国内常见的dns解析,

#dns-search localhost

dns-nameservers 8.8.8.8#谷歌dns解析,但是速度较慢

配置好后就重启网卡:sudo /etc/init.d/networking restart

即可查看修改后的系统IP信息。如果无networking文件,则自己创建。

执行该命令时,可能出现的错误:

[....] Restarting networking (via systemctl): networking.serviceJob for networking.service failed because the control process exited with error code. See "systemctl status networking.service" and "journalctl -xe" for details.

failed!

后来发现出现这个错误的原因,是因为Ubuntu16.04中的网卡名称不是eth0。

具体是网卡名称可以通过ifocnfig命令查看,我的机子的网卡名称为enp0s25,有些机子的网卡名称可能是ens33,将eth0改成自己的机子的网卡名称,然后保存推出,重启网络,发现成功了!大功告成。

Ubuntu16.04配置静态IP地址的更多相关文章

  1. Ubuntu12.04配置静态ip地址

    Ubuntu12.04配置静态ip地址 $sudo gedit /etc/network/interfaces 原有内容只有如下两行: auto lo iface lo inet loopback 向 ...

  2. Ubuntu16.04配置静态ip

    1.安装好ubuntu16.04虚拟机之后,首先按照下图的步骤进行: 首先需要打开虚拟网络编辑器,点击VMnet8的虚拟网卡,如果没有这个网卡,只需在编辑虚拟机设置里面将网络适配器类型改为NAT模式, ...

  3. 软件——Ubuntu16.04设置静态ip地址

    1.获取网卡名称 在命令行输入ifconfig -a 2.修改网卡配置文件 sudo vim /etc/network/interfaces 加上下面的配置,IP地址可以成适合你的 auto eth0 ...

  4. ubuntu14.04配置静态IP地址

    1. 找到文件并作如下修改:vim /etc/network/interfaces修改如下部分:# interfaces(5) file used by ifup(8) and ifdown(8)au ...

  5. Ubuntu16.04修改静态ip地址

    https://blog.csdn.net/mdw5521/article/details/79270035

  6. 如何在Ubuntu Server 18.04 LTS中配置静态IP地址

    安装Ubuntu Server 18.04后需要分配一个的静态IP地址.先前的LTS版本Ubuntu 16.04使用/etc/network/interfaces文件配置静态IP地址,但是Ubuntu ...

  7. VMware虚拟CentOS 6.5在NAT模式下配置静态IP地址及Xshell远程控制配置

    VMware虚拟CentOS 6.5在NAT模式下配置静态IP地址及Xshell远程控制配置 标签: LinuxXshellCentOS 2016-10-15 04:58 127人阅读 评论(0) 收 ...

  8. TX2开发板Ubuntu16.04设置静态IP

    TX2开发板Ubuntu16.04设置静态IP  https://www.cnblogs.com/qilai/p/11285445.html 首先打开一个Terminal输入 ifconfig 查看自 ...

  9. Ubuntu 为网卡配置静态IP地址

    为网卡配置静态IP地址编辑文件/etc/network/interfaces:sudo vi /etc/network/interfaces并用下面的行来替换有关eth0的行:# The primar ...

随机推荐

  1. apt-get update 出现错误“ AppStream cache update completed, but some metadata was ignored due to errors. ”

    只需要 执行 sudo rm /var/lib/dpkg/lock;     之后再次执行:sudo apt-get update

  2. PageHelper分页+前台BootStrap_pagination样式/BootStrap_table样式

    一.PagerHelper分页+前台BootStrap_pagination样式: 效果: 1.引入pageHelper插件:2种方式    pageHelper所需jar包:pagehelper-5 ...

  3. 模板层template

    继续之前的views,你可 能已经注意到我们例子中视图中返回的的方式有点特别.也就是说.HTML被直接硬编码在Python代码之中 def current_datetime(request): now ...

  4. python property对象

    一.从@porperty说起 Python内置的@property装饰器是负责把一个方法变成属性调用的 class Stu(object): def __init__(self,age): self. ...

  5. zabbix环境搭建

    zabbix介绍 zabbix是一个开源的监控软件集成了nagos和cat的优势 而且有很多自带的插件可以使用,而且还有api接口供我们使用 zabbix还支持自定义监控项 初始环境- centos ...

  6. 26.HashCode

      在前面三篇博文中讲解了(HashMap.HashSet.HashTable),在其中不断地讲解他们的put和get方法,在这两个方法中计算key的hashCode应该是最重要也是最精华的部分,所以 ...

  7. position 小结

    position: static fixed relative absolute sticky 1.static static定位是HTML元素的默认值,即没有定位,元素出现在正常的流中.因此,这种定 ...

  8. #221 Iterate Through an Array with a For Loop

    迭代输出一个数组的每个元素是 JavaScript 中的常见需求, for 循环可以做到这一点. 下面的代码将输出数组 arr 的每个元素到控制台: var arr = [10,9,8,7,6];fo ...

  9. [转] Vmware vs Virtualbox vs KVM vs XEN: virtual machines performance comparison

    http://www.ilsistemista.net/index.php/virtualization/1-virtual-machines-performance-comparison.html? ...

  10. python爬虫学习之爬取全国各省市县级城市邮政编码

    实例需求:运用python语言在http://www.ip138.com/post/网站爬取全国各个省市县级城市的邮政编码,并且保存在excel文件中 实例环境:python3.7 requests库 ...