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地址的更多相关文章

  1. Linux ->> UBuntu 14.04 LTE下主机名称和IP地址解析

    UBuntu 14.04 LTE下主机名称和IP地址解析一些相关的配置文件: /etc/hosts: 主机文件.手工配置IP地址和主机名称间的映射.格式为每行一条映射条项: <machine_n ...

  2. Linux ->> UBuntu 14.04 LTE下安装Hadoop 1.2.1(伪分布模式)

    Hadoop的运行模式可分为单机模式.伪分布模式和分布模式. 首先无论哪种模式都需要安装JDK的,这一步之前的随笔Ubuntu 14.04 LTE下安装JDK 1.8中已经做了.这里就不多说了. 其次 ...

  3. Linux ->> UBuntu 14.04 LTE下安装Hadoop 1.2.1(集群分布式模式)

    安装步骤: 1) JDK -- Hadoop是用Java写的,不安装Java虚拟机怎么运行Hadoop的程序: 2)创建专门用于运行和执行hadoop任务(比如map和reduce任务)的linux用 ...

  4. Linux ->> Ubuntu 14.04 LTE下配置SSH免密码登录

    首先用apt-get命令安装SSH jerry@ubuntu:~$ sudo apt-get install ssh [sudo] password for jerry: Reading packag ...

  5. Linux ->> Ubuntu 14.04 LTE下安装JDK 1.8

    先到Oracle官网的下载中心下载JDK8的tar包到本地. 下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-dow ...

  6. 虚拟机 - NAT模式下设置静态 IP 地址

    背景 如果不给虚拟机设置静态 IP 地址的话,每次重启机器都会自动分配一个新的 IP 如果有多台虚拟机的话,也会动态获取 IP 动态IP的话,每次 设置静态 IP 的步骤 查看本机 IP 和网关 cm ...

  7. Git使用:Linux(Ubuntu 14.04 x64)下安装Git并配置连接GitHub

    github是一个非常好的网络代码托管仓库,知晓许久,但是一直没有用起来,最近才开始使用git管理自己的文档和代码. Git是非常强大的版本管理工具,今天就告诉大家,如何在Linux下安装GIt,并且 ...

  8. Linux Ubuntu 14.04 LTS下VirtualBox连接USB

    1.环境 主机:Ubuntu 14.04 LTS 虚拟机:Windows 7 专业版本 VirtualBox: 图形用户界面版本 5.1.8 r111374 (Qt5.6.1) 2.在主机上给Virt ...

  9. Centos 下设置静态ip地址

       今天小编遇到了需要设置centos(6.4) 下静态ip地址,下面把详细步骤记录下来. 1> 首先打开这个 vi /etc/sysconfig/network-scripts/ifcfg- ...

随机推荐

  1. python量化分析系列之---5行代码实现1秒内获取一次所有股票的实时分笔数据

    python量化分析系列之---5行代码实现1秒内获取一次所有股票的实时分笔数据 最近工作太忙了,有一个星期没有更新文章了,本来这一期打算分享一些对龙虎榜数据的分析结果的,现在还没有把数据内的价值很好 ...

  2. hadoop踩坑:localhost:50070 无法访问 关闭防火墙

    ubuntu 关闭防火墙:ufw disable hadoop3.0以下版本web访问端口50070:3.0及以上web访问端口9870 参考链接:https://blog.csdn.net/qq_3 ...

  3. 关于chart不能自行切换出现的报错现象

    1.echart 页面菜单不能切换,line和bar不能自行切换 页面上报错误   bar has not been reqired 解决办法,加载bar <script type=" ...

  4. php 内存共享shmop源码阅读

    多进程通信的时候,会涉及到共享内存.shmop_open()创建或打开一个内存块 PHP_FUNCTION(shmop_open) { long key, mode, size; struct php ...

  5. 关于Map集合的遍历总结

    Map集合的遍历经常遇到,今天在这里总结一下Map集合遍历的几种方式: public static void main(String[] args){ Map<String,String> ...

  6. golang 读取一行

    //读取一行 func myReadLine(paths string) error { //先获取到文件信息 fileinfo, err := os.Stat(paths) if err != ni ...

  7. deblurGAN

    -- main.py -- util.py -- data_loader.py -- mode.py -- DeblurGAN.py -- vgg19.py -- layer.py -- vgg19. ...

  8. Java 基础(8)——流程控制

    上次的运算符都消化好了吗?每一天都要用到一些哦~ 以前有提到过一嘴,程序执行都是从上到下执行的,emm,学到这里,感觉这句话是对的也是错的了…… 如果都是一行一行执行下去的话,上节课的例子: 今天不上 ...

  9. RabbitMQ如何解决各种情况下丢数据的问题

    1.生产者丢数据 生产者的消息没有投递到MQ中怎么办?从生产者弄丢数据这个角度来看,RabbitMQ提供transaction和confirm模式来确保生产者不丢消息. transaction机制就是 ...

  10. 谈谈我从工作中理解的CDN

    一.CDN定义 CDN的全称是Content Delivery Network,即内容分发网络.其基本思路是尽可能避开互联网上有可能影响数据传输速度和稳定性的瓶颈和环节,使内容传输的更快.更稳定.通过 ...