Statistics
| Branch: | Tag: | Revision:

root / kvm-ifup @ a004c27e

History | View | Annotate | Download (1.5 kB)

1
#!/bin/bash
2

    
3
# This is an example of a Ganeti kvm ifup script that configures network
4
# interfaces based on the initial deployment of the Okeanos project
5

    
6
source /etc/default/snf-network
7
source /usr/lib/snf-network/common.sh
8

    
9
FROM=FROM${INTERFACE^^}
10
TO=TO${INTERFACE^^}
11

    
12
GANETI_INSTANCE_NAME=$INSTANCE
13

    
14
try clear_routed_setup_ipv4
15
try clear_routed_setup_ipv6
16
try clear_routed_setup_firewall
17
try clear_ebtables
18
try clear_nfdhcpd
19

    
20
if [ "$MODE" = "routed" ]; then
21
  TABLE=$LINK
22
  ip link set $INTERFACE addr $TAP_CONSTANT_MAC up
23
  INDEV=$INTERFACE
24
  DROPDHCPREQCMD="iptables -A FORWARD -i $INTERFACE -p udp --dport 67 -j DROP"
25
elif [ "$MODE" = "bridged" ]; then
26
  ip link set $INTERFACE up
27
  brctl addif $BRIDGE $INTERFACE
28
  INDEV=$BRIDGE
29
  try init_ebtables
30
  DROPDHCPREQCMD="runlocked $RUNLOCKED_OPTS ebtables -A $FROM -p ipv4 --ip-protocol udp --ip-destination-port 67 -j DROP"
31
fi
32

    
33

    
34
for tag in $NETWORK_TAGS; do
35
  case $tag in
36
  $IP_LESS_ROUTED_TAG)
37
    try routed_setup_ipv4
38
    try routed_setup_ipv6
39
    try routed_setup_firewall
40
    try send_garp
41
  ;;
42
  $NFDHCPD_TAG)
43
    # Drop unicast BOOTP/DHCP packets
44
    $DROPDHCPREQCMD
45
    try setup_nfdhcpd
46
  ;;
47
  $MAC_FILTERED_TAG)
48
    try setup_ebtables
49
  ;;
50
  $MASQ_TAG)
51
    try setup_masq
52
  ;;
53
  $DNS_TAG)
54
    get_rev4_info "$IP"
55
    get_eui64 "$MAC" "$NETWORK_SUBNET6"
56
    get_rev6_info "$EUI64"
57
    $SNF_NETWORK_LOG $0 "update dns for $GANETI_INSTANCE_NAME $IP $EUI64"
58
    update_all add
59
  ;;
60

    
61
  esac
62
done
63

    
64
if [ -x "$IFUP_EXTRA_SCRIPT" ]; then
65
  exec $IFUP_EXTRA_SCRIPT "$@"
66
fi
67

    
68
exit 0