-
Notifications
You must be signed in to change notification settings - Fork 0
/
6.sh
56 lines (43 loc) · 1.32 KB
/
6.sh
1
2
3
4
5
6
7
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
#!/bin/bash
# Define the IP address of your Anycast network
ANYCAST_IP="10.0.0.1"
# Define the network interface you want to apply the Anycast IP to
INTERFACE="eth0"
# Define the path to your BIND configuration file
BIND_CONF="/etc/bind/named.conf.options"
# Backup the original BIND configuration file
sudo cp $BIND_CONF $BIND_CONF.backup
# Clear the BIND configuration file
echo "" | sudo tee $BIND_CONF
# Set the BIND configuration for Anycast
echo "options {
listen-on { $ANYCAST_IP; };
listen-on-v6 { none; };
};" | sudo tee -a $BIND_CONF
# Restart BIND
sudo systemctl restart bind9
# Install keepalived
sudo apt-get install keepalived
# Define the path to your keepalived configuration file
KEEPALIVED_CONF="/etc/keepalived/keepalived.conf"
# Backup the original keepalived configuration file
sudo cp $KEEPALIVED_CONF $KEEPALIVED_CONF.backup
# Clear the keepalived configuration file
echo "" | sudo tee $KEEPALIVED_CONF
# Set the keepalived configuration for Anycast and Load Balancing
echo "vrrp_instance VI_1 {
state MASTER
interface $INTERFACE
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
$ANYCAST_IP
}
}" | sudo tee -a $KEEPALIVED_CONF
# Restart keepalived
sudo systemctl restart keepalived