blob: cff3fb78b46d102c544bd297f35f99f77d1c0c05 [file] [log] [blame]
Andy Bavier8d51c6c2015-04-01 11:40:22 -04001#!/bin/sh
2
3SHELL="/bin/bash"
4
5NIC=$( route|grep default|awk '{print$8}' )
6
7NAME="${1}"
8OP="${2}"
9SUBOP="${3}"
10ARGS="${4}"
11
12add_port_fwd_rule() {
13 DPORT=$1
14 VM=$2
15 TOPORT=$3
16
17 VMIP=$( getent ahosts $VM|head -1|awk '{print $1}' )
18 iptables -t nat -C PREROUTING -p tcp -i $NIC --dport $DPORT -j DNAT --to-destination $VMIP:$TOPORT
19 if [ "$?" -ne 0 ]
20 then
21 iptables -t nat -A PREROUTING -p tcp -i $NIC --dport $DPORT -j DNAT --to-destination $VMIP:$TOPORT
22 fi
23}
24
25if [ "$OP" = "start" ] || [ "$OP" = "reload" ]
26then
27 iptables -t nat -F
28 add_port_fwd_rule 35357 keystone 35357
29 add_port_fwd_rule 4990 keystone 4990
30 add_port_fwd_rule 5000 keystone 5000
31 add_port_fwd_rule 8774 nova-cloud-controller 8774
32 add_port_fwd_rule 9696 nova-cloud-controller 9696
33 add_port_fwd_rule 9292 glance 9292
34 add_port_fwd_rule 8080 openstack-dashboard 80
35 add_port_fwd_rule 3128 nagios 80
36 add_port_fwd_rule 8777 ceilometer 8777
37
38 # Also flush the filter table before rules re-added
39 iptables -F
40fi