~openstack-gd/nova/nova-avail-zones

« back to all changes in this revision

Viewing changes to plugins/xenserver/networking/etc/init.d/host-rules

  • Committer: Ilya Alekseyev
  • Date: 2010-12-29 14:17:06 UTC
  • mfrom: (478.1.24 nova)
  • Revision ID: ialekseev@griddynamics.com-20101229141706-idx1r9z54841h7rj
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#
 
3
# host-rules          Start/Stop the networking host rules
 
4
#
 
5
# chkconfig: 2345 85 15
 
6
# description: Networking Host Rules for Multi Tenancy Protections
 
7
 
 
8
# Copyright 2010 OpenStack LLC.
 
9
# All Rights Reserved.
 
10
#
 
11
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
12
#    not use this file except in compliance with the License. You may obtain
 
13
#    a copy of the License at
 
14
#
 
15
#         http://www.apache.org/licenses/LICENSE-2.0
 
16
#
 
17
#    Unless required by applicable law or agreed to in writing, software
 
18
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
19
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
20
#    License for the specific language governing permissions and limitations
 
21
#    under the License.
 
22
 
 
23
IPTABLES=/sbin/iptables
 
24
EBTABLES=/sbin/ebtables
 
25
ARPTABLES=/sbin/arptables
 
26
 
 
27
iptables-up()
 
28
{
 
29
        $IPTABLES -P FORWARD DROP
 
30
        $IPTABLES -A FORWARD -m physdev --physdev-in eth0 -j ACCEPT
 
31
        $IPTABLES -A FORWARD -m physdev --physdev-in eth1 -j ACCEPT
 
32
}
 
33
 
 
34
ebtables-up()
 
35
{
 
36
        $EBTABLES -P FORWARD DROP
 
37
        $EBTABLES -A FORWARD -o eth0 -j ACCEPT
 
38
        $EBTABLES -A FORWARD -o eth1 -j ACCEPT
 
39
}
 
40
 
 
41
arptables-up()
 
42
{
 
43
        $ARPTABLES -P FORWARD DROP
 
44
        $ARPTABLES -A FORWARD --opcode Request --in-interface eth0 -j ACCEPT
 
45
        $ARPTABLES -A FORWARD --opcode Reply --in-interface eth0 -j ACCEPT
 
46
        $ARPTABLES -A FORWARD --opcode Request --in-interface eth1 -j ACCEPT
 
47
        $ARPTABLES -A FORWARD --opcode Reply --in-interface eth1 -j ACCEPT
 
48
}
 
49
 
 
50
iptables-down()
 
51
{
 
52
        $IPTABLES -P FORWARD ACCEPT
 
53
        $IPTABLES -D FORWARD -m physdev --physdev-in eth0 -j ACCEPT
 
54
        $IPTABLES -D FORWARD -m physdev --physdev-in eth1 -j ACCEPT
 
55
}
 
56
 
 
57
ebtables-down()
 
58
{
 
59
        $EBTABLES -P FORWARD ACCEPT
 
60
        $EBTABLES -D FORWARD -o eth0 -j ACCEPT
 
61
        $EBTABLES -D FORWARD -o eth1 -j ACCEPT
 
62
}
 
63
 
 
64
arptables-down()
 
65
{
 
66
        $ARPTABLES -P FORWARD ACCEPT
 
67
        $ARPTABLES -D FORWARD --opcode Request --in-interface eth0 -j ACCEPT
 
68
        $ARPTABLES -D FORWARD --opcode Reply --in-interface eth0 -j ACCEPT
 
69
        $ARPTABLES -D FORWARD --opcode Request --in-interface eth1 -j ACCEPT
 
70
        $ARPTABLES -D FORWARD --opcode Reply --in-interface eth1 -j ACCEPT
 
71
}
 
72
 
 
73
start()
 
74
{
 
75
        iptables-up
 
76
        ebtables-up
 
77
        arptables-up
 
78
}
 
79
 
 
80
stop()
 
81
{
 
82
        iptables-down
 
83
        ebtables-down
 
84
        arptables-down
 
85
}
 
86
 
 
87
case "$1" in
 
88
        start)
 
89
                start
 
90
                RETVAL=$?
 
91
                ;;
 
92
        stop)
 
93
                stop
 
94
                RETVAL=$?
 
95
                ;;
 
96
        restart)
 
97
                stop
 
98
                start
 
99
                RETVAL=$?
 
100
                ;;
 
101
        *)
 
102
                echo $"Usage: $0 {start|stop|restart}"
 
103
                exit 1
 
104
                ;;
 
105
esac
 
106
exit $RETVAL