打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Linux单网卡绑定多IP
方法一
在/etc/sysconfig/network-scripts/下创建ifcfg-eth0:x网卡配置文件,通过此配置文件来绑定IP,最多可绑定255个IP。
[root@info ~]# cd /etc/sysconfig/network-scripts/
[root@info network-scripts]# pwd
/etc/sysconfig/network-scripts
[root@info network-scripts]# cp ifcfg-eth0 ifcfg-eth0:1
[root@info network-scripts]# vi ifcfg-eth0:1
DEVICE=eth0:1 #设备名称
ONBOOT=yes
BOOTPROTO=static
IPADDR=172.16.0.100 #绑定IP地址
NETMASK=255.255.0.0
GATEWAY=172.16.1.1
 
重启网路服务
[root@info network-scripts]# service network restart
正在关闭接口 eth0:                                        [  确定  ]
关闭环回接口:                                             [  确定  ]
设置网络参数:                                             [  确定  ]
弹出环回接口:                                             [  确定  ]
弹出界面 eth0:                                            [  确定  ]
弹出界面 eth0.tmp:                                        [  确定  ]
 
[root@info network-scripts]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:84:F8:33 
          inet addr:192.168.1.90  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe84:f833/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1177 errors:0 dropped:0 overruns:0 frame:0
          TX packets:965 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:92683 (90.5 KiB)  TX bytes:92726 (90.5 KiB)
          Interrupt:185 Base address:0x2000
 
eth0:1    Link encap:Ethernet  HWaddr 00:0C:29:84:F8:33 
          inet addr:172.16.0.100  Bcast:172.16.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:185 Base address:0x2000
 
方法二
使用ifconfig 设备名 IP地址  广播地址 子网掩码来绑定IP,缺陷是当系统重启时,ifconfig绑定的参数会丢失,需手工重新配置。但可以把配置参数加入启动文件中,让其自动运行。
[root@info network-scripts]# ifconfig eth0:2 10.0.0.100 netmask 255.0.0.0
[root@info network-scripts]# vi /etc/rc.d/rc.local
 
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you dont
# want to do the full Sys V style init stuff.
 
touch /var/lock/subsys/local
ifconfig eth0:2 10.0.0.100 netmask 255.0.0.0
 
[root@info ~]# ifconfig eth0:2
eth0:2    Link encap:Ethernet  HWaddr 00:0C:29:84:F8:33 
          inet addr:10.0.0.100  Bcast:10.255.255.255  Mask:255.0.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:185 Base address:0x2000
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
CentOS 7 网络配置
Linux下一块网卡设置多个IP地址
Linux系统单网卡绑定多个IP地址
linux 配多个ip给一张网卡
(1)Redhat如何查看和修改IP地址
RedHat网络配置方法
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服