Linux ->> UBuntu 14.04 LTE下设置静态IP地址
UBuntu 14.04 LTE设置IP地址和一些服务器版本的Linux还不太一样。以Centos 7.0为例,网卡IP地址的配置文件应该是/etc/sysconfig/network-scripts/ifcfg-eth0
首先UBuntu 14.04 LTE下面IP地址的配置文件是/etc/network/interfaces。
jerry@ubuntu:/etc/network$ cat /etc/network/interfaces
# interfaces() file used by ifup() and ifdown()
auto lo
iface lo inet loopback auto eth0
iface eth0 inet static
address 192.168.2.100
gateway 192.168.2.2
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
dns-nameservers 8.8.8.8
jerry@ubuntu:/etc/network$
把地址配好后用ifdown eth0后跟上ifup eth0重启网卡让前面的配置生效
jerry@ubuntu:/etc/network$ sudo ifdown eth0
jerry@ubuntu:/etc/network$ sudo ifup eth0
jerry@ubuntu:/etc/network$ ifconfig
eth0 Link encap:Ethernet HWaddr :0c::e7:e6:
inet addr:192.168.2.100 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fee7:e657/ Scope:Link
UP BROADCAST RUNNING MULTICAST MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (31.2 KB) TX bytes: (46.4 KB) lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::/ Scope:Host
UP LOOPBACK RUNNING MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (8.3 MB) TX bytes: (8.3 MB) jerry@ubuntu:/etc/network$ ping www.baidu.com
PING www.a.shifen.com (61.135.169.121) () bytes of data.
bytes from 61.135.169.121: icmp_seq= ttl= time= ms
bytes from 61.135.169.121: icmp_seq= ttl= time=54.9 ms
^C
--- www.a.shifen.com ping statistics ---
packets transmitted, received, % packet loss, time 6396ms
rtt min/avg/max/mdev = 54.940/78.678/102.417/23.740 ms
有时你在一台刚刚安装好的Ubuntu机器上运行ifdown eth0命令可能会出现ifdown: interface eth0 not configured这样的错误提示,原因是ifdown和ifup是依据/run/network/ifstate里的内容来知道有哪些网络接口。cat一下有没有eth0,没有就添加eth0=eth0到文件的尾端。然后再运行下命令就解决了。
jerry@ubuntu:/etc/network$ sudo ifdown eth0
ifdown: interface eth0 not configured
jerry@ubuntu:/etc/network$ ifconfig
eth0 Link encap:Ethernet HWaddr :0c:::f1:cb
inet addr:192.168.2.129 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe96:f1cb/ Scope:Link
UP BROADCAST RUNNING MULTICAST MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (7.5 MB) TX bytes: (232.6 KB) lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::/ Scope:Host
UP LOOPBACK RUNNING MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (16.9 KB) TX bytes: (16.9 KB) jerry@ubuntu:/etc/network$ ping 192.168.2.2
PING 192.168.2.2 (192.168.2.2) () bytes of data.
bytes from 192.168.2.2: icmp_seq= ttl= time=0.328 ms
bytes from 192.168.2.2: icmp_seq= ttl= time=0.153 ms
bytes from 192.168.2.2: icmp_seq= ttl= time=0.285 ms
^C
--- 192.168.2.2 ping statistics ---
packets transmitted, received, % packet loss, time 1998ms
rtt min/avg/max/mdev = 0.153/0.255/0.328/0.075 ms
jerry@ubuntu:/etc/network$ cd /run/network/
jerry@ubuntu:/run/network$ ls
ifstate ifup.eth0 ifup.lo static-network-up-emitted
jerry@ubuntu:/run/network$ cat if
ifstate ifup.eth0 ifup.lo
jerry@ubuntu:/run/network$ cat ifstate
lo=lo
jerry@ubuntu:/run/network$ vim ifstate
jerry@ubuntu:/run/network$ sudo vim ifstate
jerry@ubuntu:/run/network$ sudo ifdown eth0
RTNETLINK answers: No such process
jerry@ubuntu:/run/network$ sudo ifup eth0
jerry@ubuntu:/run/network$ ifconfig
eth0 Link encap:Ethernet HWaddr :0c:::f1:cb
inet addr:192.168.2.129 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe96:f1cb/ Scope:Link
UP BROADCAST RUNNING MULTICAST MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (7.5 MB) TX bytes: (240.5 KB) lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::/ Scope:Host
UP LOOPBACK RUNNING MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (24.0 KB) TX bytes: (24.0 KB) jerry@ubuntu:/run/network$ ifconfig
eth0 Link encap:Ethernet HWaddr :0c:::f1:cb
inet addr:192.168.2.129 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe96:f1cb/ Scope:Link
UP BROADCAST RUNNING MULTICAST MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (7.5 MB) TX bytes: (242.1 KB) lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::/ Scope:Host
UP LOOPBACK RUNNING MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (24.0 KB) TX bytes: (24.0 KB) jerry@ubuntu:/run/network$ sudo ifdown eth0
jerry@ubuntu:/run/network$ sudo ifup eth0
jerry@ubuntu:/run/network$ ifconfig
eth0 Link encap:Ethernet HWaddr :0c:::f1:cb
inet addr:192.168.2.110 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe96:f1cb/ Scope:Link
UP BROADCAST RUNNING MULTICAST MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (7.5 MB) TX bytes: (250.3 KB) lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::/ Scope:Host
UP LOOPBACK RUNNING MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (24.5 KB) TX bytes: (24.5 KB) jerry@ubuntu:/run/network$
下面是Ubuntu的官方文档专门讲网络设置的
Linux ->> UBuntu 14.04 LTE下设置静态IP地址的更多相关文章
- Linux ->> UBuntu 14.04 LTE下主机名称和IP地址解析
UBuntu 14.04 LTE下主机名称和IP地址解析一些相关的配置文件: /etc/hosts: 主机文件.手工配置IP地址和主机名称间的映射.格式为每行一条映射条项: <machine_n ...
- Linux ->> UBuntu 14.04 LTE下安装Hadoop 1.2.1(伪分布模式)
Hadoop的运行模式可分为单机模式.伪分布模式和分布模式. 首先无论哪种模式都需要安装JDK的,这一步之前的随笔Ubuntu 14.04 LTE下安装JDK 1.8中已经做了.这里就不多说了. 其次 ...
- Linux ->> UBuntu 14.04 LTE下安装Hadoop 1.2.1(集群分布式模式)
安装步骤: 1) JDK -- Hadoop是用Java写的,不安装Java虚拟机怎么运行Hadoop的程序: 2)创建专门用于运行和执行hadoop任务(比如map和reduce任务)的linux用 ...
- Linux ->> Ubuntu 14.04 LTE下配置SSH免密码登录
首先用apt-get命令安装SSH jerry@ubuntu:~$ sudo apt-get install ssh [sudo] password for jerry: Reading packag ...
- Linux ->> Ubuntu 14.04 LTE下安装JDK 1.8
先到Oracle官网的下载中心下载JDK8的tar包到本地. 下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-dow ...
- 虚拟机 - NAT模式下设置静态 IP 地址
背景 如果不给虚拟机设置静态 IP 地址的话,每次重启机器都会自动分配一个新的 IP 如果有多台虚拟机的话,也会动态获取 IP 动态IP的话,每次 设置静态 IP 的步骤 查看本机 IP 和网关 cm ...
- Git使用:Linux(Ubuntu 14.04 x64)下安装Git并配置连接GitHub
github是一个非常好的网络代码托管仓库,知晓许久,但是一直没有用起来,最近才开始使用git管理自己的文档和代码. Git是非常强大的版本管理工具,今天就告诉大家,如何在Linux下安装GIt,并且 ...
- Linux Ubuntu 14.04 LTS下VirtualBox连接USB
1.环境 主机:Ubuntu 14.04 LTS 虚拟机:Windows 7 专业版本 VirtualBox: 图形用户界面版本 5.1.8 r111374 (Qt5.6.1) 2.在主机上给Virt ...
- Centos 下设置静态ip地址
今天小编遇到了需要设置centos(6.4) 下静态ip地址,下面把详细步骤记录下来. 1> 首先打开这个 vi /etc/sysconfig/network-scripts/ifcfg- ...
随机推荐
- ionic3 pop到指定页面
this.navCtrl.getViews().forEach(element => { if(element.name == 'JiecheHomePage'){ this.navCtrl.p ...
- Comparing deep learning frameworks: Tensorflow, CNTK, MXNet, & Caffe
https://imaginghub.com/blog/10-a-comparison-of-four-deep-learning-frameworks-tensorflow-cntk-mxnet-a ...
- restsharp 组件调用返回 gbk 编码的api,中文乱码解决方法。(restsharp response 中文乱码 gbk)
最近要调一个restful风格的api 用了 一个开源第三方组件,组件还是蛮好用的, 支持直接按参数定义实体类,然后发起请求之前直接 addobject 的方式就把请求参数给添加进去了, 解码的时候可 ...
- EasyNetQ自定义异常消息处理
20140310补充: rabbitmq有requeue属性,可以选择消息是否返回队列,另,本文的解决方式非常之山寨,只能应用于发送和接收方式. 这几天在折腾消息队列,在.Net环境下有基于Rabbi ...
- vue 坑之 vuex requires a Promise polyfill in this browser
android内嵌H5页面不显示出现这个问题,原因有很多 首先,别急,请看下面的推荐方案: 1.找个Android真机测试下(机型版本为4.4以上),真机联调测试 Android 只需要四个步骤: 1 ...
- 在windows服务器上设置301、伪静态(wordpress)
新建一个httpd.ini文件,插入代码: [ISAPI_Rewrite] RewriteCond Host: ^wuchao\.cc$ RewriteRule (.*) http\://www\.w ...
- ACS蚁群算法求解对称TSP旅行商问题的JavaScript实现
本来以为在了解蚁群算法的基础上实现这道奇怪的算法题并不难,结果实际上大相径庭啊.做了近三天时间,才改成现在这能勉强拿的出手的模样.由于公式都是图片,暂且以截图代替那部分内容吧,mark一记. 1 蚁群 ...
- render函数的使用
render函数的几种使用方法最近使用element-ui的tree组件时,需要在组件树的右边自定义一些图标,就想到了用render函数去渲染. <el-tree class="p-t ...
- https Java SSLException protocol_version的问题解决方法
我们的业务代码里有需要用爬虫爬取商品的图片地址,然后在转到我们的服务器里的过程,中间当然少不了下载图片的过程,最近目标网站有些改变,就是之前http前缀的图片地址部分改成了https,然后就造成了一个 ...
- ActiveMQ - 入门指南
首先需要下载ActiveMQ,下面的链接给我们列出了所有版本: http://activemq.apache.org/download-archives.html 每个版本为不同的OS提供了链接: 公 ...