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,如需转载请自行联系原作者

相关文章
|
监控 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
616 20
|
网络协议 Linux Python
Python脚本配置Centos静态ip地址
这是一个Python脚本,用于自动化配置CentOS系统的静态IP地址。脚本创建或修改文件,填写接口名(如ens33)、IP地址、子网掩码、网关和DNS。运行时需替换变量值并使用`sudo`以管理员权限执行。完成配置后,它会重启网络服务。注意,用户应根据实际网络环境调整参数。
442 4
Python脚本配置Centos静态ip地址
|
Ubuntu 网络协议 Linux
liunx各大发行版(centos,rocky,ubuntu,国产麒麟kylinos)网卡配置和包管理方面的区别
本文对比了Linux主要发行版CentOS、Rocky Linux、Ubuntu及国产Kylin在网卡配置与包管理上的差异。
1757 1
成功解决:CentOS7中无法连接网络
这篇文章介绍了如何解决CentOS 7虚拟机无法连接网络的问题。作者猜测问题可能是由于虚拟机软件的网关和CentOS 7系统的网关不一致导致的。文章提供了两种解决方案:修改虚拟网络编辑器的网关或修改CentOS系统的网关和IP地址。作者选择了后者,并演示了如何在CentOS终端中以root用户身份修改IP和网关。
成功解决:CentOS7中无法连接网络
|
网络协议 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信息。
732 5
|
Ubuntu 网络协议 Linux
liunx各大发行版(centos,rocky,ubuntu,国产麒麟kylinos)网卡配置和包管理方面的区别
liunx各大发行版(centos,rocky,ubuntu,国产麒麟kylinos)网卡配置和包管理方面的区别
970 0
|
网络协议 Linux
centos7部分桥接网络ping不通解决方案
centos7部分桥接网络ping不通解决方案
|
网络协议 Linux 网络安全
Hyper-v 如何配置 Centos7 虚拟机网络?
Hyper-v 如何配置 Centos7 虚拟机网络?
1106 0
|
Linux
Linux——Centos8虚拟机添加网卡未显示
Linux——Centos8虚拟机添加网卡未显示
681 0