blob: 8d9102b7b75c7ed45e5d8f873cca7961cf0f3f02 [file] [log] [blame]
Zack Williams3db3b962016-03-01 21:59:25 -07001#!/bin/sh
2
3SHELL="/bin/bash"
4
5NIC=$( route|grep default|awk '{print $NF}' )
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 neutron-api 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