**环境: **RHEL6.4

**需求: **Linux一块网卡添加多个IP地址

一、临时生效

二、永久生效

当前eth0的配置:

# ifconfig
eth0 Link encap:Ethernet HWaddr 2A:2E:BE:CF:8C:DC
inet addr:192.168.99.159 Bcast:192.168.99.255 Mask:255.255.255.0
inet6 addr: fe80::282e:beff:fecf:8cdc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:32955247 errors:0 dropped:0 overruns:0 frame:0
TX packets:3800040 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:15964502776 (14.8 GiB) TX bytes:11315742252 (10.5 GiB)
Interrupt:247

一、临时生效

1.1 网卡eth0添加一个IP地址

```
ifconfig eth0 add 10.10.10.159
```
**查看:**
```
# ifconfig -a
eth0 Link encap:Ethernet HWaddr 2A:2E:BE:CF:8C:DC
inet addr:192.168.99.159 Bcast:192.168.99.255 Mask:255.255.255.0
inet6 addr: fe80::282e:beff:fecf:8cdc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:32958394 errors:0 dropped:0 overruns:0 frame:0
TX packets:3800101 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:15965401503 (14.8 GiB) TX bytes:11315752846 (10.5 GiB)
Interrupt:247

eth0:0 Link encap:Ethernet HWaddr 2A:2E:BE:CF:8C:DC

inet addr:10.10.10.159 Bcast:192.168.99.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

Interrupt:247

发现多了一个基于eth0的eth0:0的虚拟接口。
<h2 id="1.2">1.2 修改eth0:0的广播地址</h2>

ifconfig eth0:0 broadcast 10.10.10.255

**查看:**

ifconfig -a

eth0 Link encap:Ethernet HWaddr 2A:2E:BE:CF:8C:DC

inet addr:192.168.99.159 Bcast:192.168.99.255 Mask:255.255.255.0

inet6 addr: fe80::282e:beff:fecf:8cdc/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:32959543 errors:0 dropped:0 overruns:0 frame:0

TX packets:3800126 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:15965717592 (14.8 GiB) TX bytes:11315758056 (10.5 GiB)

Interrupt:247

eth0:0 Link encap:Ethernet HWaddr 2A:2E:BE:CF:8C:DC

inet addr:10.10.10.159 Bcast:10.10.10.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

Interrupt:247

成功修改了eth0:0的广播地址。

<h1 id="2">二、永久生效</h1>
<h2 id="2.1">2.1 编辑ifcfg-eth0:0</h2>
配置文件在`/etc/sysconfig/network-scripts/`路径下。

cd /etc/sysconfig/network-scripts/

more ifcfg-eth0

DEVICE=eth0

TYPE=Ethernet

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=static

IPADDR=192.168.99.159

NETMASK=255.255.255.0

more ifcfg-eth0:0

DEVICE=eth0:0

TYPE=Ethernet

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=static

IPADDR=10.10.10.159

NETMASK=255.255.255.0

如果还想添加IP地址,可以同理编辑`ifcfg-eth0:1`文件.

<h2 id="2.2">2.2 重启网卡生效配置</h2>
### 2.2.1 可以重启整个网络服务: ###

service network restart

### 2.2.2 也可针对eth0网卡,关闭再启动: ###

ifdown eth0

ifup eth0

### 2.2.3 最后看eth0网卡信息如下: ###
ifconfig查看eth0的网卡信息:

ifconfig

eth0 Link encap:Ethernet HWaddr 2A:2E:BE:CF:8C:DC

inet addr:192.168.99.159 Bcast:192.168.99.255 Mask:255.255.255.0

inet6 addr: fe80::282e:beff:fecf:8cdc/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:32989071 errors:0 dropped:0 overruns:0 frame:0

TX packets:3800770 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:15974202540 (14.8 GiB) TX bytes:11315842294 (10.5 GiB)

Interrupt:247

eth0:0 Link encap:Ethernet HWaddr 2A:2E:BE:CF:8C:DC

inet addr:10.10.10.159 Bcast:10.10.10.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

Interrupt:247

eth0:1 Link encap:Ethernet HWaddr 2A:2E:BE:CF:8C:DC

inet addr:10.11.11.159 Bcast:10.11.11.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

Interrupt:247

Linux一块网卡添加多个IP地址的更多相关文章

  1. 使用powershell为物理网卡添加多个IP地址

    因特殊要求,需要给某物理网卡添加多个IP地址: powershell中有个netsh的命令,添加IPv4地址的方法: add address [name=]<字符串>       [[ad ...

  2. 虚拟机下linux 系统网卡配置、固定IP地址

    1.进入该目录下修改内容 vi       /etc/sysconfig/network-scripts/  ifcfg-eth0 TYPE=Ethernet BOOTPROTO=static DEF ...

  3. Linux 一块网卡配置多个IP的方法

    1:ifconfig eth0:0 192.168.211.200/24 up 2:ip addr add 192.168.211.201/24 dev eth0 labe eth0:1 man ip ...

  4. linux系统单网卡绑定多个IP地址

    说明: 单网卡绑定两个IP地址,电信和联通,目的:是为了当电信出故障联通正常使用. 系 统 IP地址 子网掩码 网关 CentOS 6.3_64bit eth0:116.18.176.19 255.2 ...

  5. LINUX单网卡绑定多个IP

    在linux下,我们有时候需要给单网卡设置不同的IP地址,这样就涉及到单网卡绑定多个IP地址的情况.使用本方法可以方便的为单网卡绑定多个IP地址.笔者使用的环境是centos5.6,应该在fedora ...

  6. VMware 虚拟机 linux执行 ifconfig 命令 eth0没有IP地址(intet addr、Bcast、Mask) UP BROADCAST MULTICAST 问题

    VMware 虚拟机 linux执行 ifconfig 命令 eth0没有IP地址(intet addr.Bcast.Mask) UP BROADCAST MULTICAST 问题 eth0:网络接口 ...

  7. 在CentOS 7上给一个网卡分配多个IP地址

    有时你也许想要给一个网卡多个地址.你该怎么做呢?另外买一个网卡来分配地址?在小型网络中其实不用这么做.我们现在可以在CentOS/RHEL 7中给一个网卡分配多个ip地址.想知道怎么做么?好的,跟随我 ...

  8. Centos7 网卡DHCP重新获取IP地址

    问题:局域网内一台linux系统(Centos7.4)DHCP自动获取的IP地址和另一台手动配置的静态IP冲突了 解决方法:让DHCP自动获取的IP地址重新获取一个别的IP地址 DHCP重新获取IP ...

  9. Linux查询一台机器的IP地址和其对应的域名

    Linux查询一台机器的IP地址和其对应的域名 youhaidong@youhaidong-ThinkPad-Edge-E545:~$ nslookup > 127.0.0.1 Server: ...

随机推荐

  1. Android--Intent传递对象

    Intent 传递对象通常有两种实现方式,Serializable 和 Parcelable: 一.Serializable:序列化,表示将一个对象转换成可存储或可传输的状态,序列化后的对象可以在网络 ...

  2. Hibernate -- A unidirectional one-to-one association on a foreign key

    at sometime we usually need to create two tables that one table relate another.Such as a husband onl ...

  3. objective-c(框架)

    框架指objective-c的foundation库,下面的例子中给出几个常见用的类及其方法. 数值对象 NSNumber *intNum; NSNumber *longNum; NSNumber * ...

  4. 最少知识原则(Least Knowledge Principle)

    最少知识原则(Least Knowledge Principle),或者称迪米特法则(Law of Demeter),是一种面向对象程序设计的指导原则,它描述了一种保持代码松耦合的策略.其可简单的归纳 ...

  5. java提高篇(二五)-----HashTable

          在java中与有两个类都提供了一个多种用途的hashTable机制,他们都可以将可以key和value结合起来构成键值对通过put(key,value)方法保存起来,然后通过get(key ...

  6. [ACM_贪心] Radar Installation

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=28415#problem/A 题目大意:X轴为海岸线可放雷达监测目标点,告诉n个目标点和雷 ...

  7. Gradle中的buildScript代码块

    在编写Gradle脚本的时候,在build.gradle文件中经常看到这样的代码: build.gradle 1 2 3 4 5 6 7 8 9 buildScript { repositories ...

  8. How to Change RabbitMQ Queue Parameters in Production?

    RabbitMQ does not allow re-declaring a queue with different values of parameters such as durability, ...

  9. Senparc.Weixin.MP SDK 微信公众平台开发教程(五):使用Senparc.Weixin.MP SDK

    Senparc.Weixin.MP SDK已经涵盖了微信6.x的所有公共API. 整个项目的源代码以及已经编译好的程序集可以在这个项目中获取到:https://github.com/JeffreySu ...

  10. How to fix updating ubuntu apt-get problem

    It's my new PC with a new os of ubuntu. every time when I want to install software or update apt-get ...