Linux一块网卡添加多个IP地址
**环境: **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地址的更多相关文章
- 使用powershell为物理网卡添加多个IP地址
因特殊要求,需要给某物理网卡添加多个IP地址: powershell中有个netsh的命令,添加IPv4地址的方法: add address [name=]<字符串> [[ad ...
- 虚拟机下linux 系统网卡配置、固定IP地址
1.进入该目录下修改内容 vi /etc/sysconfig/network-scripts/ ifcfg-eth0 TYPE=Ethernet BOOTPROTO=static DEF ...
- 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 ...
- linux系统单网卡绑定多个IP地址
说明: 单网卡绑定两个IP地址,电信和联通,目的:是为了当电信出故障联通正常使用. 系 统 IP地址 子网掩码 网关 CentOS 6.3_64bit eth0:116.18.176.19 255.2 ...
- LINUX单网卡绑定多个IP
在linux下,我们有时候需要给单网卡设置不同的IP地址,这样就涉及到单网卡绑定多个IP地址的情况.使用本方法可以方便的为单网卡绑定多个IP地址.笔者使用的环境是centos5.6,应该在fedora ...
- 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:网络接口 ...
- 在CentOS 7上给一个网卡分配多个IP地址
有时你也许想要给一个网卡多个地址.你该怎么做呢?另外买一个网卡来分配地址?在小型网络中其实不用这么做.我们现在可以在CentOS/RHEL 7中给一个网卡分配多个ip地址.想知道怎么做么?好的,跟随我 ...
- Centos7 网卡DHCP重新获取IP地址
问题:局域网内一台linux系统(Centos7.4)DHCP自动获取的IP地址和另一台手动配置的静态IP冲突了 解决方法:让DHCP自动获取的IP地址重新获取一个别的IP地址 DHCP重新获取IP ...
- Linux查询一台机器的IP地址和其对应的域名
Linux查询一台机器的IP地址和其对应的域名 youhaidong@youhaidong-ThinkPad-Edge-E545:~$ nslookup > 127.0.0.1 Server: ...
随机推荐
- 新装ubuntu12.04需要敲的命令集合
1.sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup sudo gedit /etc/apt/sources.list copy: ...
- 练习2-3:十六进制数字字符串转换为等价整型值,字符串允许包含的数字包括:0~9、a~f、A~F、x、X(C程序设计语言 第2版)
#include <stdio.h> #include <string.h> #include <math.h> int htoi(char s[]){ unsig ...
- PDF2
itex生成PDF文档示例 package dao.other; import java.awt.Color; import java.io.File; import java.io.FileInpu ...
- PyCharm 3.0 发布,提供免费开源版本
PyCharm 发布最新的 3.0 版本,该版本新特性详见: http://www.jetbrains.com/pycharm/whatsnew/index.html 该版本最主要的是提供了免费开源的 ...
- guzzle调用失败-缺少guzzle
用composer安装了,但是目前为止还有问题.开发环境是 WAMP PHP5.4.12. 已经打开PHP.ini 的SSL扩展,现在还是提示缺少 curl-ca-bundle.cr 报错 No sy ...
- Windows Azure 服务器时间问题
最近一直在做学校的一个小项目,前期在没有服务器端的情况下意淫做出来了手机客户端.在寒假里使用ASP.NET快速做了一个网站并且设计好了需要使用其他内容,在Windows Azure上测试评估,为学校的 ...
- 分布式系统一致性问题和Raft一致性算法
一致性问题 一致性算法是用来解决一致性问题的,那么什么是一致性问题呢? 在分布式系统中,一致性问题(consensus problem)是指对于一组服务器,给定一组操作,我们需要一个协议使得最后它们的 ...
- Java虚拟机9:Java类加载机制
前言 我们知道我们写的程序经过编译后成为了.class文件,.class文件中描述了类的各种信息,最终都需要加载到虚拟机之后才能运行和使用.而虚拟机如何加载这些.class文件?.class文件的信息 ...
- resumablejs 分块上传 断点续传
http://www.resumablejs.com/ 官网 upload.html <!DOCTYPE html> <html lang="en"> &l ...
- Android SDK content Loader has encountered a problem.parseSdkContent failed
打开Eclipse,弹出Android SDK content Loader has encountered a problem.parseSdkContent failed,当点击detail按钮, ...