blob: 61a4fafd105cc8623793f7b418b4017fe7eaaced [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
Andy Bavier093e6a82015-08-21 13:31:31 -040016
Andy Bavier8d51c6c2015-04-01 11:40:22 -040017 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
Andy Bavier093e6a82015-08-21 13:31:31 -040032 add_port_fwd_rule 9696 neutron-api 9696
Andy Bavier8d51c6c2015-04-01 11:40:22 -040033 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
Andy Bavier093e6a82015-08-21 13:31:31 -040040fi