作者:妩媚芙蓉糕 | 来源:互联网 | 2023-09-07 19:03
2019独角兽企业重金招聘Python工程师标准配置bond0上联网络设备也需要做捆绑,如果是冗余的bond则上联不用配置H3Cs5560交换机interfaceBridge
2019独角兽企业重金招聘Python工程师标准>>>
配置bond0上联网络设备也需要做捆绑,如果是冗余的bond则上联不用配置
H3Cs5560交换机
interface Bridge-Aggregation 1
port access vlan 10
#创建聚合口,划入vlan
int g 1/0/1
port link-aggregation group 1
#聚合的两个物理口都加入集合组
int g 2/0/1
port link-aggregation g 1
服务器
bond0配置cat ifcfg-bond0
DEVICE=bond0
BOOTPROTO=static
IPADDR=10.0.0.126
NETMASK=255.0.0.0
GATEWAY=10.0.0.1
OnBOOT=yes
USERCTL=no
TYPE=Ethernet
eth1,2…配置cat ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
OnBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes
配置文件开机启用bond0
vim /etc/modprobe.d/openfwwf.conf
alias bond0 bonding
options bond0 miimon=1000 mode=0
命令方式启用bond0模块
insmod /lib/modules/`uname -r`/kernel/drivers/net/bonding/bonding.ko miimon=1000 mode=0
其他配置
删除模块命令
rmmod /lib/modules/`uname -r`/kernel/drivers/net/bonding/bonding.ko miimon=1000 mode=0
license原因bond指定配置文件mac地址MACADDR=mac地址
查看状态
cat /proc/net/bonding/bond*
#查看bond状态 ethtool bond0| grep -i speed #查看网卡速率如:Speed: 2000Mb/s display link-aggregation verbose | include /0/2 #Status状态为 ‘S’
配置脚本.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# --------------------------------------------------
#Author: Lghost
#Email: admin@attacker.club
#Site: attacker.club
#Site:ops.attacker.club Mail:admin@attacker.club
#Date:2017-09-05 21:28:39 Last:2017-09-09 14:07:11
#Description:
# --------------------------------------------------
import sys,os,re
ip = "192.168.16.25"
netmask = "255.255.254.0"
gateway = "192.168.16.1"
bOnd= "0"
def warn (Text):
print ">>>>>\t\033[1;31m%s\033[0m\t<<<<<" % Text
def info (Text):
print ">>>>>\t\033[1;33m%s\033[0m\t<<<<<" % Text
#提示
def shell(cmd):
os.system(cmd)
def shellinfo(cmd):
r=os.popen(cmd)
text=r.read()
r.close()
return text
#shell
def file(path,method,content):
f=open(path,method)
f.write(content)
f.close()
#file
if __name__ == "__main__":
ethx_info = shellinfo("ip add |grep ^2|awk '{print $2}'")
eth0 = (re.match('\w+\d',ethx_info).group())
ethx_info = shellinfo("ip add |grep ^3|awk '{print $2}'")
eth1 = (re.match('\w+\d',ethx_info).group())
file('/etc/sysconfig/network-scripts/ifcfg-%s' % eth0,'w',
'''DEVICE=%s
BOOTPROTO=none
OnBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes
''' % (eth0))
file('/etc/sysconfig/network-scripts/ifcfg-%s' % eth1,'w',
'''DEVICE=%s
BOOTPROTO=none
OnBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes
''' % (eth1))
file('/etc/sysconfig/network-scripts/ifcfg-bond0','w',
'''DEVICE=bond0
BOOTPROTO=static
IPADDR=%s
NETMASK=%s
GATEWAY=%s
OnBOOT=yes
USERCTL=no
TYPE=Ethernet
''' % (ip,netmask,gateway))
file('/etc/modprobe.d/bond.conf','w',
'''
alias bond bonding
options bond0 miimon=1000 mode=%s
'''% (bond)
info('配置文件修改完毕')
info('本机地址:%s' % ip)
warn('重启网卡中。。。')
shell( 'service network restart')
转:https://my.oschina.net/attacker/blog/3009199