create_ospf_conf.sh 3.32 KB
Newer Older
1 2 3 4 5 6
#!/bin/bash
source net_info.sh
OSPF="ospf6d.conf"
ETC="/usr/local/etc/"


7
META="hostname ospf6d@plant\npassword zebra\nlog file /users/quagga/ospf.log\nservice advanced-vty\n!"
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
echo "!" > $OSPF
echo -e $META >> $OSPF

#NODE1
hn=$(hostname | awk -F'.' '{print $1}')
if [ "$hn" == "node1" ]; then
	echo "#Node $hn..."
	echo "interface $n1_a_dev" >> $OSPF
	echo "interface $n1_1_dev" >> $OSPF
	echo "interface lo" >> $OSPF
	echo "router ospf6" >> $OSPF
	echo "   router-id 0.0.0.2" >> $OSPF
	echo "   area 0.0.0.0 range $n1_a/80" >> $OSPF
	echo "	 interface $n1_a_dev area 0.0.0.0" >> $OSPF
	echo "   area 0.0.0.0 range $n1_1/80" >> $OSPF
	echo "	 interface $n1_1_dev area 0.0.0.0" >> $OSPF
	echo "   area 0.0.0.0 range $n1_lb/80" >> $OSPF
	echo "	 interface lo area 0.0.0.0" >> $OSPF
fi


#NODE2
hn=$(hostname | awk -F'.' '{print $1}')
if [ "$hn" == "node2" ]; then
	echo "#Node $hn..."
	echo "interface $n2_a_dev" >> $OSPF
	echo "interface $n2_b_dev" >> $OSPF
	echo "interface $n2_c_dev" >> $OSPF
	echo "interface lo" >> $OSPF
	echo "router ospf6" >> $OSPF
	echo "   router-id 0.0.0.2" >> $OSPF
	echo "   area 0.0.0.0 range $n2_a/80" >> $OSPF
	echo "	 interface $n2_a_dev area 0.0.0.0" >> $OSPF
	echo "   area 0.0.0.0 range $n2_b/80" >> $OSPF
	echo "	 interface $n2_b_dev area 0.0.0.0" >> $OSPF
	echo "   area 0.0.0.0 range $n2_c/80" >> $OSPF
	echo "	 interface $n2_c_dev area 0.0.0.0" >> $OSPF
	echo "   area 0.0.0.0 range $n2_lb/80" >> $OSPF
	echo "	 interface lo area 0.0.0.0" >> $OSPF
fi


#NODE3
hn=$(hostname | awk -F'.' '{print $1}')
if [ "$hn" == "node3" ]; then
	echo "#Node $hn..."
	echo "interface $n3_b_dev" >> $OSPF
	echo "interface $n3_d_dev" >> $OSPF
	echo "interface $n3_e_dev" >> $OSPF
	echo "interface lo" >> $OSPF
	echo "router ospf6" >> $OSPF
	echo "   router-id 0.0.0.3" >> $OSPF
	echo "   area 0.0.0.0 range $n3_b/80" >> $OSPF
	echo "	 interface $n3_b_dev area 0.0.0.0" >> $OSPF
	echo "   area 0.0.0.0 range $n3_d/80" >> $OSPF
	echo "	 interface $n3_d_dev area 0.0.0.0" >> $OSPF
	echo "   area 0.0.0.0 range $n3_e/80" >> $OSPF
	echo "	 interface $n3_e_dev area 0.0.0.0" >> $OSPF
	echo "   area 0.0.0.0 range $n3_lb/80" >> $OSPF
	echo "	 interface lo area 0.0.0.0" >> $OSPF
fi


#NODE4
hn=$(hostname | awk -F'.' '{print $1}')
if [ "$hn" == "node4" ]; then
	echo "#Node $hn..."
	echo "interface $n4_c_dev" >> $OSPF
	echo "interface $n4_d_dev" >> $OSPF
	echo "interface lo" >> $OSPF
	echo "router ospf6" >> $OSPF
	echo "   router-id 0.0.0.4" >> $OSPF
	echo "   area 0.0.0.0 range $n4_c/80" >> $OSPF
	echo "	 interface $n4_c_dev area 0.0.0.0" >> $OSPF
	echo "   area 0.0.0.0 range $n4_d/80" >> $OSPF
	echo "	 interface $n4_d_dev area 0.0.0.0" >> $OSPF
	echo "   area 0.0.0.0 range $n4_lb/80" >> $OSPF
	echo "	 interface lo area 0.0.0.0" >> $OSPF
fi

#NODE5
hn=$(hostname | awk -F'.' '{print $1}')
if [ "$hn" == "node5" ]; then
	echo "#Node $hn..."
	echo "interface $n5_e_dev" >> $OSPF
	echo "interface $n5_2_dev" >> $OSPF
	echo "interface lo" >> $OSPF
	echo "router ospf6" >> $OSPF
	echo "   router-id 0.0.0.2" >> $OSPF
	echo "   area 0.0.0.0 range $n5_e/80" >> $OSPF
	echo "	 interface $n5_e_dev area 0.0.0.0" >> $OSPF
	echo "   area 0.0.0.0 range $n5_2/80" >> $OSPF
	echo "	 interface $n5_2_dev area 0.0.0.0" >> $OSPF
	echo "   area 0.0.0.0 range $n5_lb/80" >> $OSPF
	echo "	 interface lo area 0.0.0.0" >> $OSPF
fi


echo "line vty" >> $OSPF

cat $OSPF
sudo cp $OSPF $ETC
exit 0