#!/bin/bash echo "-----------------------------" echo "Get MAC & IPs information ..." echo "-----------------------------" MAC_A="00:A0:F4:DE:AD:11" MAC_B="00:A0:F4:DE:AD:22" IP_A="192.168.33.187" MASK_A="255.255.255.0" GW_A="0.0.0.0" IP_B="3.111.33.187" MASK_B="255.255.255.0" GW_B="0.0.0.0" sleep 1 echo "----------------------------------" echo "Set eth1 & eth2 interfaces down .." echo "----------------------------------" ifconfig eth1 0.0.0.0 down ifconfig eth2 0.0.0.0 down sleep 5 echo "-----------------------------------------------------" echo "Set MAC address ${MAC_A} to eth1 & eth2 interfaces .." echo "-----------------------------------------------------" ifconfig eth1 hw ether ${MAC_A} ifconfig eth2 hw ether ${MAC_B} sleep 5 echo "--------------------------------" echo "Set eth1 & eth2 interfaces up .." echo "--------------------------------" ifconfig eth1 up ifconfig eth2 up sleep 5 echo "-------------------------------------------------" echo "Create br0 interface and add eth1 & eth2 ports .." echo "-------------------------------------------------" brctl addbr br0 brctl addif br0 eth1 brctl addif br0 eth2 sleep 5 echo "--------------------" echo "Start bridge br0 ..." echo "--------------------" brctl stp br0 on sleep 5 echo "---------------------" echo "Set rstp settings ..." echo "---------------------" mstpctl settreeprio br0 0 8 mstpctl settreeportprio br0 eth1 0 8 mstpctl setportpathcost br0 eth1 200000 mstpctl settreeportprio br0 eth2 0 8 mstpctl setportpathcost br0 eth2 200000 sleep 5 echo "---------------------------------------" echo "Switch bridge mode from stp to rstp ..." echo "---------------------------------------" mstpctl setforcevers br0 rstp sleep 5 echo "---------------------------------------" echo "Set br0 with IP=${IP_A} interface up .." echo "---------------------------------------" ifconfig br0 ${IP_A} netmask ${MASK_A} up sleep 5 echo "------------------------------------" echo "RSTP ready for PTP configuration ..." echo "------------------------------------" ifconfig > /tmp/start_redundancy.ok sleep 5