Zack Williams | 3db3b96 | 2016-03-01 21:59:25 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | SHELL="/bin/bash" |
| 4 | |
| 5 | NIC=$( route|grep default|awk '{print $NF}' ) |
| 6 | |
| 7 | NAME="${1}" |
| 8 | OP="${2}" |
| 9 | SUBOP="${3}" |
| 10 | ARGS="${4}" |
| 11 | |
| 12 | add_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 | |
| 25 | if [ "$OP" = "start" ] || [ "$OP" = "reload" ] |
| 26 | then |
| 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 |
| 40 | fi |