Almost embarrassed to post this but it's one of the few times I can't put in to words (properly) what I'm trying to do and Google it.
I have a hosted Ubuntu server with two public IPs. The host machine will have some services available to it and then I have LXC containers setup with their own private /24 and masqueraded out.
The problem is that everything funnels through the primary public IP and I need all traffic coming from the LXC containers to come from the secondary public IP while leaving the host traffic alone.
Here's the layout:
eth0 1.1.1.2/24 gateway of 1.1.1.1
eth0:1 1.1.1.3/24
lxcbr0 10.0.3.1/24
iptables (current):
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- 10.0.3.0/24 !10.0.3.0/24
I tried:
iptables -t nat -I POSTROUTING 1 -s 10.0.3.0/24 -o eth0:1 -j SNAT --to-source 1.1.1.2
and
iptables -t nat -I POSTROUTING 1 -s 10.0.3.0/24 -o lxcbr0 -j SNAT --to-source 1.1.1.2
To no avail. I'm sure I'm doing it wrong as I'm not as well versed in iptables as other firewalls.