vm-cloudinit-brocluster.file 1.59 KB
Newer Older
1
#!/bin/bash -x
2 3 4 5

ETH1_CFG='/etc/network/interfaces.d/eth1.cfg'
sudo echo "auto eth1" > $ETH1_CFG
sudo echo "iface eth1 inet dhcp" >> $ETH1_CFG
6
sudo echo "dns-nameservers 8.8.8.8" >> $ETH1_CFG
7

8
sudo echo "127.0.0.1 $HOSTNAME" >> /etc/hosts
9

10
sudo ifup eth1
11

12 13
echo "PATH=$PATH:/usr/local/bro/bin" >> ~/.bashrc

14
ETH1_IP=`ifconfig eth1 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://'`
15
echo "Enable promisc mode"
16
sudo ifconfig eth1 promisc
17 18 19
echo "disable tcp checksum offloading"
sudo ethtool --offload  eth1  rx off  tx off
sudo ethtool -k eth1 gso off
20 21 22
echo "Drop all outgoing packets in bro interface"
sudo iptables -A OUTPUT -o eth1 -j DROP
echo "Accept all incoming packets in bro interface"
23
sudo iptables -A INPUT -i eth1 -j ACCEPT
24
BRO_CFG_FILE='/usr/local/bro/etc/node.cfg'
25 26 27 28
mkdir -p /usr/local/bro/etc/ 

#setup the cron task
SCALE_SCRIPT='/home/ubuntu/idsScale.sh'
29 30
sudo crontab -u root -l | { cat; echo "*/5 * * * * $SCALE_SCRIPT"; } | sudo crontab -u root -
sudo crontab -u root -l
31 32 33 34 35 36 37 38 39 40

#start creating the file conf for 4 instance
echo "[manager]" > $BRO_CFG_FILE
echo "type=manager" >> $BRO_CFG_FILE
echo "host=$ETH1_IP" >> $BRO_CFG_FILE

echo "" >> $BRO_CFG_FILE

echo "[proxy-0]" >> $BRO_CFG_FILE
echo "type=proxy" >> $BRO_CFG_FILE
41
echo "host=localhost" >> $BRO_CFG_FILE
42 43 44 45 46

echo "" >> $BRO_CFG_FILE

echo "[worker-0]" >> $BRO_CFG_FILE
echo "type=worker" >> $BRO_CFG_FILE
47
echo "host=localhost" >> $BRO_CFG_FILE
48 49 50 51 52 53 54
echo "interface=eth1">> $BRO_CFG_FILE
echo "lb_method=pf_ring" >> $BRO_CFG_FILE

echo "" >> $BRO_CFG_FILE

echo "lb_procs=4" >> $BRO_CFG_FILE

55 56 57 58
cd /home/ubuntu
echo "Starting BRO IDS.."
sudo ./startbro.exp
cd -