forked from KusakabeShi/ospf-ibgp-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
up.sh
executable file
·37 lines (31 loc) · 920 Bytes
/
up.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
#!/bin/bash
resolveip()
{
: ${1:?Usage: resolve name}
(
PATH=$PATH:/usr/bin
lookupresult=$(getent ahostsv4 "$1")
if [ $? -eq 0 ]; then
resultaddr=$(echo $lookupresult | head -n 1 | awk '{print $1}')
echo $resultaddr
return 0
fi
lookupresult=$(getent ahostsv6 $1)
if [ $? -eq 0 ]; then
resultaddr=$(echo $lookupresult | head -n 1 | awk '{print $1}')
echo "[$resultaddr]"
return 0
fi
echo "0.0.0.0"
return 127
)
}
set -x
python3 update_cost.py --cost 9999
ip link add dummy-{{ netname }} type dummy || true
ip link set dummy-{{ netname }} up || true
{% if ipv4 is defined and ipv4 != None %}ip addr add {{ self_ip.v4 }}/32 dev dummy-{{ netname }} || true{% endif %}
{% if ipv4 is defined and ipv6 != None %}ip addr add {{ self_ip.v6 }}/128 dev dummy-{{ netname }} || true{% endif %}
{% for up in ups -%}
{{ up }}
{% endfor %}