delete_ip_from_iface \
$CTDB_NATGW_PUBLIC_IFACE $_ip $_maskbits >/dev/null 2>&1
- for _net in $CTDB_NATGW_STATIC_ROUTES ; do
+ for _net_gw in $CTDB_NATGW_STATIC_ROUTES ; do
+ _net="${_net_gw%@*}"
ip route del "$_net" metric 10 >/dev/null 2>/dev/null
done
-d $ctdb_natgw_public_ip_host -j REJECT 2>/dev/null
ip addr add $CTDB_NATGW_PUBLIC_IP dev $CTDB_NATGW_PUBLIC_IFACE
- if [ -n "$CTDB_NATGW_DEFAULT_GATEWAY" ] ; then
- for _net in $CTDB_NATGW_STATIC_ROUTES ; do
- ip route add "$_net" metric 10 via $CTDB_NATGW_DEFAULT_GATEWAY
- done
- fi
+ for _net_gw in $CTDB_NATGW_STATIC_ROUTES ; do
+ _net="${_net_gw%@*}"
+ if [ "$_net" != "$_net_gw" ] ; then
+ _gw="${_net_gw#*@}"
+ else
+ _gw="$CTDB_NATGW_DEFAULT_GATEWAY"
+ fi
+
+ [ -n "$_gw" ] || continue
+ ip route add "$_net" metric 10 via "$_gw"
+ done
}
natgw_set_slave ()
{
_natgwip="$1"
- for _net in $CTDB_NATGW_STATIC_ROUTES ; do
+ for _net_gw in $CTDB_NATGW_STATIC_ROUTES ; do
+ _net="${_net_gw%@*}"
ip route add "$_net" via "$_natgwip" metric 10
done
</varlistentry>
<varlistentry>
- <term>CTDB_NATGW_STATIC_ROUTES=<parameter>IPADDR/MASK</parameter> ...</term>
+ <term>CTDB_NATGW_STATIC_ROUTES=<parameter>IPADDR/MASK[@GATEWAY]</parameter> ...</term>
<listitem>
<para>
Each IPADDR/MASK identifies a network or host to which
can not reach required infrastructure, that overrides
the NAT gateway default route.
</para>
+ <para>
+ If GATEWAY is specified then the corresponding route on
+ the NATGW master node will be via GATEWAY. Such routes
+ are created even if
+ <varname>CTDB_NATGW_DEFAULT_GATEWAY</varname> is not
+ specified. If GATEWAY is not specified for some
+ networks then routes are only created on the NATGW
+ master node for those networks if
+ <varname>CTDB_NATGW_DEFAULT_GATEWAY</varname> is
+ specified.
+ </para>
<para>
This should be used with care to avoid causing traffic
to unnecessarily double-hop through the NAT gateway