Search code examples
ipdebianiptablesnat

2 services on same port on 2 different IP address on one physical server


I have an OVH debian server with 2 IP addresses :

  • eth0 inet adr:5.39.78.122 (physical)

  • eth0:0 inet adr:188.142.57.137 (failover)

I need to configure 2 different services on the same port 32 :

  • One that will reply on 188.142.57.137:32

  • The second one that will route 5.39.78.122:32 => 188.142.57.137:3232

I think that I can do it with iptables nat table but I don't know how to ?

Someone can explain me ?

Thanks


Solution

  • Thanks great !!! It works fine !!!

    I used this tuto for first step setting Iptables :

    https://wiki.debian.org/iptables

    And add theses lines at the end :

    *nat
    :PREROUTING ACCEPT [0:0]
    :POSTROUTING ACCEPT [0:0]
    :OUTPUT ACCEPT [0:0]
    -A PREROUTING --dst 5.39.78.122 -p tcp --dport 32 -j DNAT --to-destination 188.142.57.137:3232
    COMMIT