CentOS 添加绑定某个范围内的 IP 地址
CentOS 在同一网卡配置文件下添加多个 IP 可以用 IPADDRx 参数(x 是从 0 开始的连续整数)。也可以创建多个网卡配置文件,例如 ifcfg-eth0:x 这样以此类推,每个配置文件绑定 1 个 IP。
上述方法适合添加少量或不连续 IP 时使用,当要配置大量连续 IP 则可以用另一个方法,更加简单。
CentOS 添加某个 CIDR 范围 IP 地址
1. 进入网卡配置文件目录,找到当前配置外网连接的主网卡。假设网卡名为 ifcfg-eth1。
cd /etc/sysconfig/network-scripts && vi ifcfg-eth1
将文件内的 NM_CONTROLLED 参数设为 no(没有则添加该参数),使之摆脱可能受到 NetworkManager 程序的控制影响。
NM_CONTROLLED=no
2. 创建添加 IP 范围的配置文件,命名方式在网卡名称后加-range0
。若要添加多个 IP 范围,则相应创建多个 range 配置文件,例如 range0,range1,range2 这样。
vi ifcfg-eth1-range0
配置文件内容参数如下(不必添加 DEVICE、ONBOOT、GATEWAY 等参数)。
IPADDR_START=1.1.1.1 # IP 范围内首个可用 IP IPADDR_END=1.1.1.30 # IP 范围内最后可用 IP NETMASK=255.255.255.224 # 子网掩码,也可以用 PREFIX=27 参数设置,是同样作用 CLONENUM_START=0 # 设置网卡别名的起始数,0 表示从 eth1:0 开始添加 IP # 假设添加 IP 范围有 30 个 IP,设置后会自动生成 eth1:0 - eth1:29 # 正确方法是设置具体值前,先用 ifconfig 查询当前网卡别名使用情况 # 假设已存在 eth1:0,则值必须向推后,使用 1 或其它没有被使用的 ID NO_ALIASROUTING=yes # 设置数据包不走网卡别名,而是通过 eth1 网卡,可提高路由响应速度
示例添加 1.1.1.1/27
范围 IP,计算可用 IP 范围和子网掩码可以用这个在线工具。
前缀大小 | 子网掩码 | 可用 IP 数 | 所能划分的子网数 | 划分后的总可用 IP 数 |
---|---|---|---|---|
/24 | 255.255.255.0 | 254 | 1 | 254 |
/25 | 255.255.255.128 | 126 | 2 | 252 |
/26 | 255.255.255.192 | 62 | 4 | 248 |
/27 | 255.255.255.224 | 30 | 8 | 240 |
/28 | 255.255.255.240 | 14 | 16 | 224 |
/29 | 255.255.255.248 | 6 | 32 | 192 |
/30 | 255.255.255.252 | 2 | 64 | 128 |
/31 | 255.255.255.254 | 2 | 128 | 256 |
延伸:IP 段分类有 A、B、C 三种。在 IP 地址的四段号码中,前 1 段网络号后 3 段本地号为 A 类,前 2 段网络号后 2 段本地号为 B 类,前 3 段网络号后 1 段本地号为 C 类。通常普通用户能拥有 IP 段是 C 类 |
3. 正确完成上面设置后,service network restart
重启网络生效。在这过程会自动逐个添加 IP,耐心等待其完成,之后随机 ping 几个 IP 检查是否绑定成功。
本文方法同样适用其他 RHEL 系操作系统,例如 Fedora、ClearOS等。
如果不想麻烦手动配置,网上看到有个自动配置脚本(未测试),有兴趣的可以试试。
how long for careprost to work https://carepro1st.com/
dapoxetine for women’s libido https://salemeds24.wixsite.com/dapoxetine
hydroxychloroquine 200mg side effects https://hydroxychloroquine.webbfenix.com/
prices for ivermectin https://ivermectin.mlsmalta.com/
hydroxychloroquine coronavirus dosage https://hydroxychloroquine.mlsmalta.com/
mobile pharmacy generic ivermectin https://ivermectin.webbfenix.com/
cialis 20 mg generic http://www.lm360.us/
keflex for dogs ear infection https://keflex.webbfenix.com/
sildenafil tadalafil dosage equivalent http://droga5.net/
hydroxychloroquine for sale amazon https://hhydroxychloroquine.com/
vietnamese vidalista ingredients https://vidalista.mlsmalta.com/
viagra versus vidalista results https://vidalista40mg.mlsmalta.com/
buy cialis viagra https://wisig.org/
Over The Counter Cialis Easettenex buy cialis online with prescription Alicky Diflucan Online Uk
is ventolin a generic for albuterol sulfate https://amstyles.com/
is generic dapoxetine available yet https://ddapoxetine.com/
active ingredients in hydroxychloroquine https://hydroxychloroquinee.com/
tadalafil side effects from mayo clinic https://tadalafili.com/
hydroxychloroquine and zithromax https://hydroxychloroquine.lm360.us/
free printable coupons for medications https://buymeds.mlsmalta.com/
free printable coupons for medications https://medpills.bee-rich.com/
best time to take cialis https://tadalafil365.online/
best time to take cialis https://atadalafil.online/
sildenafil dapoxetine tablets https://dapoxetine.confrancisyalgomas.com/
cost of aralen without insurance https://hydroxychloroquine.mymvrc.org/
vidalista 20 rxtoed http://viidalista.co/
viagra prescription online canada https://zsildenafil.com/
cialis without a doctor prescription http://ciialis.co/
generic tadalafil usa https://tadalafil.cleckleyfloors.com/
aurogra 100mg price walgreens https://aurogra.buszcentrum.com/
hydroxychloroquine purchase online https://hydroxychloroquine4u.com/
cvs prescription cost estimator https://buymeds.mlsmalta.com/
cvs prescription cost estimator https://edmeds.buszcentrum.com/
cialis pills for men http://tadalafila.online/
low cost cialis 20mg http://cialis.audiovideoninja.com/
low cost cialis 20mg https://cialis.bee-rich.com/
can cialis cause back pain https://cialis.adicbc.com/
can cialis cause back pain https://cialis.grassfed.us/
buy cialis online https://cialzi.com/
It’s truly very complicated in this busy life to listen news on TV, thus I simply use the web for that purpose,
and take the most recent news. http://antiibioticsland.com/Augmentin.htm
Great delivery. Outstanding arguments. Keep up the amazing work. http://cialis.anafassia.com/tadalafil
An intriguing discussion is worth comment.
I think that you ought to write more on this topic, it
may not be a taboo subject but generally people don’t speak about these topics.
To the next! Kind regards!! https://hydroxychloroquineg.grassfed.us/
What’s Taking place i’m new to this, I stumbled upon this I have found It positively useful and it has aided me out loads. I am hoping to contribute & aid other customers like its aided me. Great job.
http://www.vreyrolinomit.com/