0

In a dedicated server with several containers behind NAT, I'm trying to route the output / outbound traffic from one of the containers through a specific virtual interface attached to the main physical interface. Both interfaces have public IPs assigned to them.

The chain would look as follows:

OpenVZ container (10.10.10.2) > Host system (eth0:0; IP:1.2.3.4) > internet

as opposed to the current

OpenVZ container (10.10.10.2) > Host system (eth0; IP:5.6.7.8) > internet

I believe this can be done with an iptables postrouting rule

1
  • Tried with 'route add -host 10.10.10.2 dev eth0:0' but then the inbound routing is lost.
    – manchine
    May 16, 2015 at 1:27

1 Answer 1

0

As it turned out, a simple postrouting rule did the trick.

iptables -t nat -A POSTROUTING -s '10.10.10.0/24' -o eth0 -j SNAT --to 1.2.3.4

I also had to delete a bunch of MASQUERADE postrouting rules that were just creating a big mess.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .