• centos下多网卡做bond脚本


    多网卡或者单网卡形式下的网卡bonding

    #! /bin/sh
    #获取当前网卡数
    ethnum=`lspci | grep Ethernet | wc -l`
    echo $ethnum
    #如果网卡数小于等于1则什么都不做
    if [ $ethnum -le 1 ]
            then
            echo "do nothing!"
    fi
    #如果网卡数大于等于2则
    if [ $ethnum -ge 2 ]
            then
    
        
    #-------  添加一个bond0的网卡
        echo "DEVICE=bond0" > /etc/sysconfig/network-scripts/ifcfg-bond0
        echo "ONBOOT=yes" >> /etc/sysconfig/network-scripts/ifcfg-bond0
        echo "IPADDR=192.168.3.104" >> /etc/sysconfig/network-scripts/ifcfg-bond0
        echo "NETMASK=255.255.0.0" >> /etc/sysconfig/network-scripts/ifcfg-bond0
        echo "GATEWAY=192.168.1.1" >> /etc/sysconfig/network-scripts/ifcfg-bond0
        echo "BOOTPROTO=static" >> /etc/sysconfig/network-scripts/ifcfg-bond0
        echo "USERCTL=no" >> /etc/sysconfig/network-scripts/ifcfg-bond0
    #--------
        echo "ifenslave bond0" >> /etc/rc.local
    #--------写其他网卡的配置文件
        for i in $(seq $ethnum);
        do
    num=`expr $i - 1`
            echo "BOOTPROTO=none" >  /etc/sysconfig/network-scripts/ifcfg-eth$num
            echo "DEVICE=eth$num" >>  /etc/sysconfig/network-scripts/ifcfg-eth$num
            echo "ONBOOT=yes" >>  /etc/sysconfig/network-scripts/ifcfg-eth$num
            echo "MASTER=bond0" >>  /etc/sysconfig/network-scripts/ifcfg-eth$num
            echo "USERCTL=no" >>  /etc/sysconfig/network-scripts/ifcfg-eth$num
            echo "SLAVE=yes" >>  /etc/sysconfig/network-scripts/ifcfg-eth$num
            sed -i 's/ifenslave.*/& eth'"$num"'/g' /etc/rc.local
        done;
    echo "alias bond0 bonding" > /etc/modprobe.d/modprobe.conf
    echo "options bond0 miimon=100 mode=balance-rr" >> /etc/modprobe.d/modprobe.conf
            modprobe bonding
        /etc/init.d/network   restart
    fi
    

    更新历史

    why when
    创建 2013年08月06日
    更新 2019年12月9日
  • 相关阅读:
    selenium+python+API分类总结
    Web自动化测试之六、Selenium Web控件交互
    五、Selenium元素定位的八种方法
    五、X-PATH定位元素
    五、css_selector定位总结
    pytest测试框架实战一
    python实战2
    pycharm 远程开发
    python 虚拟环境
    爬虫案例_网易云歌单
  • 原文地址:https://www.cnblogs.com/zphj1987/p/13575262.html
Copyright © 2020-2023  润新知