Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
Use MASQUERADE instead of SNAT for container NAT
Browse files Browse the repository at this point in the history
When warden is running on hosts with multiple networks, the address
associated with the default route should not always be used as the
source of the traffic. By using MASQUERADE, the packets will pick up the
address associated with adapter used to flow the request.
  • Loading branch information
sykesm committed May 11, 2015
1 parent f16abb3 commit dadb440
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions warden/root/linux/net.sh
Expand Up @@ -188,11 +188,11 @@ function setup_nat() {
--jump ${nat_postrouting_chain}

# Enable NAT for traffic coming from containers
(iptables -t nat -S ${nat_postrouting_chain} | grep -q "\-j SNAT\b") ||
(iptables -t nat -S ${nat_postrouting_chain} | grep -q "\-j MASQUERADE\b") ||
iptables -t nat -A ${nat_postrouting_chain} \
--source ${POOL_NETWORK} \
--jump SNAT \
--to $(external_ip)
! --destination ${POOL_NETWORK} \
--jump MASQUERADE
}

case "${1}" in
Expand Down

0 comments on commit dadb440

Please sign in to comment.