CentOS 网络基础:(5)设置多网卡绑定单IP

简介:

操作示例:将eth01/eth02绑定到一个IP上

(1)在修改内核模块配置文件/etc/modprobe.conf,加入以下内容:

1
2
3
4
###### Bonding Start ######
alias  bond0 bonding
options bonding max_bonds = 1
###### Bonding End ########

(2)建立bonding网卡文件/etc/sysconfig/network-scripts/ifcfg-bond0,配置如下:

1
2
3
4
5
6
7
DEVICE=bond0
ONBOOT= yes
BOOTPROTO=static
IPADDR=192.168.100.21
NETMASK=255.255.255.0
USERCTL=no
BONDING_OPTS= "mode=1 miimon=100 primary=eth01"

*bonding_opts参数参考:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
parm:           max_bonds:Max number of bonded devices (int)
parm:           tx_queues:Max number of transmit queues (default = 16) (int)
parm:           num_grat_arp:Number of gratuitous ARP packets to send on failover event (int)
parm:           num_unsol_na:Number of unsolicited IPv6 Neighbor Advertisements packets to send on failover event (int)
parm:           miimon:Link check interval  in  milliseconds (int)
parm:           updelay:Delay before considering link up,  in  milliseconds (int)
parm:           downdelay:Delay before considering link down,  in  milliseconds (int)
parm:           use_carrier:Use netif_carrier_ok (vs MII ioctls)  in  miimon; 0  for  off, 1  for  on (default) (int)
parm:           mode:Mode of operation; 0  for  balance-rr, 1  for  active-backup, 2  for  balance-xor, 3  for  broadcast, 4  for  802.3ad, 5  for  balance-tlb, 6  for  balance-alb (charp)
parm:           primary:Primary network device to use (charp)
parm:           primary_reselect:Reselect primary slave once it comes up; 0  for  always (default), 1  for  only  if  speed of primary is better, 2  for  only on active slave failure (charp)
parm:           lacp_rate:LACPDU tx rate to request from 802.3ad partner; 0  for  slow, 1  for  fast (charp)
parm:           ad_select:803.ad aggregation selection logic; 0  for  stable (default), 1  for  bandwidth, 2  for  count (charp)
parm:           xmit_hash_policy:balance-xor and 802.3ad hashing method; 0  for  layer 2 (default), 1  for  layer 3+4, 2  for  layer 2+3 (charp)
parm:           arp_interval:arp interval  in  milliseconds (int)
parm:           arp_ip_target:arp targets  in  n.n.n.n form (array of charp)
parm:           arp_validate:validate src /dst  of ARP probes; 0  for  none (default), 1  for  active, 2  for  backup, 3  for  all (charp)
parm:           fail_over_mac:For active-backup,  do  not  set  all slaves to the same MAC; 0  for  none (default), 1  for  active, 2  for  follow (charp)
parm:           all_slaves_active:Keep all frames received on an interfaceby setting active flag  for  all slaves; 0  for  never (default), 1  for  always. (int)
parm:           resend_igmp:Number of IGMP membership reports to send on link failure (int)

(3)修改eth01的网卡配置文件:

1
2
3
4
5
DEVICE=eth01
MASTER=bond0
SLAVE= yes
HWADDR=54:22:22:00:7A:37:CE
ONBOOT= yes

修改eth02的网卡配置文件:

1
2
3
4
5
DEVICE=eth02
MASTER=bond0
SLAVE= yes
HWADDR=54:22:22:00:7A:37:CE
ONBOOT= yes

(4)导入bonding驱动,重启网络服务后生效

1
2
>modprobe -i bonding max_bonds=1
>service network restart





本文转自 bannerpei 51CTO博客,原文链接:http://blog.51cto.com/281816327/1615281,如需转载请自行联系原作者

相关文章
|
5月前
|
Linux Shell
在Linux、CentOS7中设置shell脚本开机自启动服务
以上就是在CentOS 7中设置shell脚本开机自启动服务的全部步骤。希望这个指南能帮助你更好地管理你的Linux系统。
377 25
|
6月前
|
Web App开发 运维 Linux
破防了!原来CentOS联网设置竟藏在这个路径?网友:5年运维都白干了!
默认情况下,新装的 CentOS 无法直接上网。可通过点击桌面右上角的网络图标,启动 `eth0` 连接网络。为实现自动连接,右键该图标选择“编辑连接”,在 `System eth0` 设置中勾选“自动连接”。这样配置后,系统重启也能自动联网。
197 19
破防了!原来CentOS联网设置竟藏在这个路径?网友:5年运维都白干了!
|
7月前
|
监控 Linux PHP
【02】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-2月12日优雅草简化Centos stream8安装zabbix7教程-本搭建教程非docker搭建教程-优雅草solution
【02】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-2月12日优雅草简化Centos stream8安装zabbix7教程-本搭建教程非docker搭建教程-优雅草solution
181 20
|
Linux 网络安全
杨老师课堂之关于阿里云Centos7 如何设置权限的解决方案
杨老师课堂之关于阿里云Centos7 如何设置权限的解决方案
142 0
|
10月前
|
关系型数据库 MySQL Linux
在 CentOS 7 中通过编译源码方式安装 MySQL 数据库的详细步骤,包括准备工作、下载源码、编译安装、配置 MySQL 服务、登录设置等。
本文介绍了在 CentOS 7 中通过编译源码方式安装 MySQL 数据库的详细步骤,包括准备工作、下载源码、编译安装、配置 MySQL 服务、登录设置等。同时,文章还对比了编译源码安装与使用 RPM 包安装的优缺点,帮助读者根据需求选择最合适的方法。通过具体案例,展示了编译源码安装的灵活性和定制性。
839 2
|
网络协议 Linux Python
Python脚本配置Centos静态ip地址
这是一个Python脚本,用于自动化配置CentOS系统的静态IP地址。脚本创建或修改文件,填写接口名(如ens33)、IP地址、子网掩码、网关和DNS。运行时需替换变量值并使用`sudo`以管理员权限执行。完成配置后,它会重启网络服务。注意,用户应根据实际网络环境调整参数。
256 4
Python脚本配置Centos静态ip地址
|
网络协议 Shell Linux
Shell脚本配置Centos静态ip地址
这是一个用于在CentOS上设置静态IP的Shell脚本摘要: - 脚本交互式获取用户输入的IP地址、子网掩码、网关和DNS。 - 使用`sed`命令动态更新`/etc/sysconfig/network-scripts/ifcfg-ENS33`配置文件。 - 修改`BOOTPROTO`为`static`,并设置IP、NETMASK、GATEWAY和DNS1字段。 - 用`systemctl restart network`重启网络服务。 - 提示用户新配置的静态IP信息。
373 5
|
网络协议 Linux
centos7部分桥接网络ping不通解决方案
centos7部分桥接网络ping不通解决方案
|
缓存 Linux 开发工具
centos设置ntp服务同步目标服务器时间
【7 月更文挑战第 1天】linux+centos设置ntp服务同步目标服务器时间
|
Linux Nacos
蓝易云 - CentOS7 Nacos设置开机自动重启
以上就是在CentOS 7上设置Nacos开机自动重启的详细步骤。
460 0