英文脚本
read -p "bond name:" name read -p "input first interface:" int1 read -p "input second interface:" int2 read -p "input bond type:" type read -p "ip addr:" addr if egrep "7.[0-9]" /etc/redhat-release &>/dev/null; then systemctl stop NetworkManager systemctl disable NetworkManager elif egrep "6.[0-9]" /etc/redhat-release &>/dev/null; then service NetworkManager stop chkconfig NetworkManager off fi cat > /etc/sysconfig/network-scripts/ifcfg-$name << EOF TYPE=Bond BOOTPROTO=none NAME=$name DEVICE=$name ONBOOT=yes IPADDR=$addr PREFIX=24 BONDING_MASTER=yes BONDING_OPTS="mode=$type miimon=100" EOF cat > /etc/sysconfig/network-scripts/ifcfg-$int1 << EOF TYPE=Ethernet BOOTPROTO=none NAME=$int1 DEVICE=$int1 ONBOOT=yes MASTER=$name SLAVE=yes EOF cat > /etc/sysconfig/network-scripts/ifcfg-$int2 << EOF TYPE=Ethernet BOOTPROTO=none NAME=$int2 DEVICE=$int2 ONBOOT=yes MASTER=$name SLAVE=yes EOF
中文脚本
read -p "请输入bond名称如:bond0:" name read -p "输入第一块网卡名称:" int1 read -p "输入第二块网卡名称:" int2 read -p "输入bond模式:" type read -p "请输入bond的IP地址:" addr #read -p "请输入子网掩码位数:" prefix #read -p "请输入网关地址:" gateway if egrep "7.[0-9]" /etc/redhat-release &>/dev/null; then systemctl stop NetworkManager systemctl disable NetworkManager elif egrep "6.[0-9]" /etc/redhat-release &>/dev/null; then service NetworkManager stop chkconfig NetworkManager off fi cat > /etc/sysconfig/network-scripts/ifcfg-$name << EOF TYPE=Bond BOOTPROTO=none NAME=$name DEVICE=$name ONBOOT=yes IPADDR=$addr #PREFIX=$prefix PREFIX=24 #GATEWAY=$gateway BONDING_MASTER=yes BONDING_OPTS="mode=$type miimon=100" EOF cat > /etc/sysconfig/network-scripts/ifcfg-$int1 << EOF TYPE=Ethernet BOOTPROTO=none NAME=$int1 DEVICE=$int1 ONBOOT=yes MASTER=$name SLAVE=yes EOF cat > /etc/sysconfig/network-scripts/ifcfg-$int2 << EOF TYPE=Ethernet BOOTPROTO=none NAME=$int2 DEVICE=$int2 ONBOOT=yes MASTER=$name SLAVE=yes EOF