娟斌心 发表于 2018-8-25 11:49:18

shell自动配置bond

#!/bin/bash  
#自动配置bond
  
#by liuq
  
MODPROBE="/sbin/modprobe"
  
cd /etc/sysconfig/network-scripts
  
if [ -f ifcfg-eth0 ]
  
then
  cp ifcfg-eth0 /tmp/ifcfg-eth0.bak
  cp ifcfg-eth1 /tmp/ifcfg-eth1.bak
  ETH0=eth0
  ETH1=eth1
  
elif [ -f ifcfg-em0 ]
  
then
  cp ifcfg-em1 /tmp/ifcfg-em1.bak
  cp ifcfg-em2 /tmp/ifcfg-em2.bak
  ETH0=em1
  ETH1=em2
  
fi
  
bond_add()
  
{
  
echo -n "Please input your ip address for bond0:"
  
read bond0_ipaddr
  
echo -n "Please input your ip addfress for netmask:"
  
read bond0_netmask
  
echo -n "Please input your ip address for gateway:"
  
read bond0_gateway
  
}
  
bond_add
  
cat >>ifcfg-bond0/etc/rc.local
  

  
echo "alias bond0 bonding ">>/etc/modprobe.d/dist.conf
  
echo "options bonding mode=1 miimon=100">>/etc/modprobe.d/dist.conf
  

  
$MODPROBE bonding
  

  
/etc/init.d/network restart
  

  
echo "-----------------------bond0主备状态------------------"
  
more /proc/net/bonding/bond0


页: [1]
查看完整版本: shell自动配置bond