标签:bond shell
#!/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<<EOF DEVICE="bond0" TYPE=Ethernet ONBOOT=yes BOOTPROTO=static NM_CONTROLLED=no IPADDR=$bond0_ipaddr NETMASK=$bond0_netmask GATEWAY=$bond0_gateway BONDING_OPTS="mode=1 miimon=100" USERCTL=no EOF cat >ifcfg-${ETH0}<<EOF DEVICE=${ETH}0 TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=no BOOTPROTO=static MASTER=bond0 SLAVE=yes DEFROUTE=yes IPV6INIT=no USERCTL=no EOF cat >ifcfg-${ETH1}<<EOF DEVICE=${ETH}1 TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=no BOOTPROTO=static MASTER=bond0 SLAVE=yes DEFROUTE=yes IPV6INIT=no USERCTL=no EOF echo "ifenslave bond0 ${ETH}0 ${ETH}1">>/etc/rc.local echo "route add -net 0.0.0.0/0 gw $bond0_gateway dev 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
配置很简单,只是对网卡eth0,em1稍微修改,断开eth0已测试正常
本文出自 “龙尤在飞” 博客,请务必保留此出处http://2493919.blog.51cto.com/2483919/1728361
标签:bond shell
原文地址:http://2493919.blog.51cto.com/2483919/1728361