#!/bin/bash
cd /etc/sysconfig/network-scripts
mkdir ifcf-bak
cp ifcfg-* ifcf-bak
touch ifcfg-bond0
(
cat <<EOF
DEVICE=bond0
ONBOOT=yes
IPADDR=192.168.2.2
BOOTPROTO=none
NETMASK=255.255.255.0
TYPE=Ethernet
GATEWAY=192.168.2.254
BONDING_OPTS="MODE=6 MIIMON=100"
EOF
) >ifcfg-bond0
service NetworkManager stop
chkconfig NetworkManager off
for i in $@; do
(
cat <<EOF
DEVICE=$i
ONBOOT=yes
BOOTPROTO=none
TYPE=Ethernet
EOF
) >ifcfg-$i
done
touch /etc/modprobe.d/bond0.conf
echo "alias bond0 bonding" >> /etc/modprobe.d/bond0.conf
echo "ifenslave bond0 "$@ >> /etc/rc.local
echo "nameserver 61.139.2.69">> /etc/resolv.conf
切换到root用户,执行此脚本,执行时加上需要绑定的网卡名称作为参数