Andy Bavier | 8d51c6c | 2015-04-01 11:40:22 -0400 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | SHELL="/bin/bash" |
| 4 | |
| 5 | NIC=$( route|grep default|awk '{print$8}' ) |
| 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 |
Andy Bavier | 093e6a8 | 2015-08-21 13:31:31 -0400 | [diff] [blame^] | 16 | |
Andy Bavier | 8d51c6c | 2015-04-01 11:40:22 -0400 | [diff] [blame] | 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 |
Andy Bavier | 093e6a8 | 2015-08-21 13:31:31 -0400 | [diff] [blame^] | 32 | add_port_fwd_rule 9696 neutron-api 9696 |
Andy Bavier | 8d51c6c | 2015-04-01 11:40:22 -0400 | [diff] [blame] | 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 |
Andy Bavier | 093e6a8 | 2015-08-21 13:31:31 -0400 | [diff] [blame^] | 40 | fi |