Add interfaces example
[snf-network] / clear-tap
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 DEFAULT=/etc/default/snf-network
7 NFDHCPD_STATE_DIR=/var/lib/nfdhcpd
8 source $DEFAULT
9
10 function clear_routed_setup_ipv4 {
11
12  arptables -D OUTPUT -o $INTERFACE --opcode request -j mangle
13  while ip rule del dev $INTERFACE; do :; done
14  iptables -D FORWARD -i $INTERFACE -p udp --dport 67 -j DROP
15
16 }
17
18 function clear_routed_setup_ipv6 {
19
20  while ip -6 rule del dev $INTERFACE; do :; done
21
22 }
23
24
25 function clear_routed_setup_firewall {
26
27   for oldchain in protected unprotected limited; do
28     iptables  -D FORWARD -o $INTERFACE -j $oldchain
29     ip6tables -D FORWARD -o $INTERFACE -j $oldchain
30   done
31
32 }
33
34 function clear_ebtables {
35   TAP=$INTERFACE
36   FROM=FROM${TAP^^}
37   TO=TO${TAP^^}
38
39   ebtables -D INPUT -i $TAP -j $FROM
40   ebtables -D FORWARD -i $TAP -j $FROM
41   ebtables -D FORWARD -o $TAP -j $TO
42   ebtables -D OUTPUT -o $TAP -j $TO
43
44   ebtables -X $FROM
45   ebtables -X $TO
46 }
47
48
49 if [ $# -ne 1 ]; then
50   echo "Usage: $0 <tap>"
51   exit 1
52 fi
53
54 INTERFACE=$1
55
56 clear_routed_setup_ipv4 
57 clear_routed_setup_ipv6 
58 clear_routed_setup_firewall 
59 clear_ebtables 
60
61 rm $NFDHCPD_STATE_DIR/$INTERFACE