此脚本适用于Centos7/Redhat7及以上操作系统。
请根据实际情况修改
#!/bin/bash # This Scripe Come From Fasteda.cn echo Please enter the ip address: read ip echo Please enter the netmask 0-32: read mask echo Please enter the Getway: read gateway echo Please enter the DNS: read dns echo Please enter the eth1 name: read eth1 echo Please enter the eth2 name: read eth2 echo Please selete team runner: echo " (1 for broadcast, 2 for activebackup, 3 for roundrobin (default), 4 for loadbalance)" read mode case $mode in 1) nmcli con add type team con-name team0 ifname team0 config '{"runner":{"name":"broadcast"}}';; 2) nmcli con add type team con-name team0 ifname team0 config '{"runner":{"name":"activebackup"}}';; 3) nmcli con add type team con-name team0 ifname team0 config '{"runner":{"name":"roundrobin"}}';; 4) nmcli con add type team con-name team0 ifname team0 config '{"runner":{"name":"loadbalance"}}';; *) echo -e "\e[1;30minput runner $mode error, use default runner(roundrobin)\e[0m" nmcli con add type team con-name team0 ifname team0 config '{"runner":{"name":"roundrobin"}}';; esac nmcli con add type team-slave con-name team0-port1 ifname $eth1 master team0 nmcli con add type team-slave con-name team0-port2 ifname $eth2 master team0 nmcli con mod team0 ipv4.addresses "$ip/$mask" nmcli con mod team0 ipv4.gateway "$gateway" nmcli con mod team0 ipv4.dns "$dns" nmcli con mod team0 ipv4.method manual nmcli con up team0
网友留言: