From ef4a85e5b5fe554137f923a156b5537ff5d54216 Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Sat, 19 Jun 2010 18:51:16 -0700 Subject: submission in reponse to forum posting on multiple entries found in snat table with adsl dhcp configuration: http://www.vyatta.org/forum/viewtopic.php?t=4254 --- src/lbdecision.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/lbdecision.cc') diff --git a/src/lbdecision.cc b/src/lbdecision.cc index c1731fe..22d56a9 100644 --- a/src/lbdecision.cc +++ b/src/lbdecision.cc @@ -211,8 +211,13 @@ LBDecision::update_paths(LBData &lbdata) if (lbdata._disable_source_nat == false) { if (new_addr != iter->second._address) { - int err = execute(string("iptables -t nat -D WANLOADBALANCE -m connmark --mark ") + buf + " -j SNAT --to-source " + iter->second._address, stdout); - err |= execute(string("iptables -t nat -A WANLOADBALANCE -m connmark --mark ") + buf + " -j SNAT --to-source " + new_addr, stdout); + int err = 0; + if (iter->second._address.empty() == false) { + int err = execute(string("iptables -t nat -D WANLOADBALANCE -m connmark --mark ") + buf + " -j SNAT --to-source " + iter->second._address, stdout); + } + if (new_addr.empty() == false) { + err |= execute(string("iptables -t nat -A WANLOADBALANCE -m connmark --mark ") + buf + " -j SNAT --to-source " + new_addr, stdout); + } if (err == 0) { //only set if both are 0 iter->second._address = new_addr; } -- cgit v1.2.3