Author Topic: I need an internal host go out through another external IP.  (Read 1214 times)

Gilberto Ferreira

  • Zen Hero
  • *****
  • Posts: 516
  • Karma: +12/-1
    • View Profile
I need an internal host go out through another external IP.
« on: April 02, 2021, 04:04:27 pm »
Hello guys.

I need to create an iptables rule that causes an internal host to outgoing via a different public IP.
Let's say you have 2 public IPs:
aaa.bbb.ccc.ddd
aaa.bbb.ccc.eee

The end ddd is standard.
The end eee would be the secondary.

It turns out that Zentyal, at least in version 6.2, does not let me insert a second network interface using the same network.
For example, eth0 has the ip aaa.bbb.ccc.ddd, eth1 and eth2 have internal IP's and eth3 would have the aaa.bbb.ccc.eee IP which would be the secondary one.
But when I try to insert the IP into eth3 he says that there is already an IP of that network configured in eth0!
So what I did was set up a virtual interface hanging on eth0 with the ip aaa.bbb.ccc.eee, type eth0: 1.
Then I tried to create an SNAT rule but it doesn't work. When I go to the internal host it still takes the default external IP aaa.bbb.ccc.ddd.

I installed an IPFIRE (www.ipfire.org) which is very simple and in it I managed to do it smoothly.
BTW, ​​it was from this IPFIRE that I took the rule of iptables.
I tried like this:
iptables -N NAT_SOURCE
iptables -t nat POSTROUTING -j NAT_SOURCE
ptables -t nat -A NAT_SOURCE -s IP / 32 -j SNAT --to-source aaa.bbb.ccc.eee

But without success!

Thanks to anyone who can help me.
« Last Edit: April 04, 2021, 02:13:27 pm by Gilberto Ferreira »