Posts Tagged ‘route’

Redirecting outgoing traffic ….

Monday, December 15th, 2008

It may become necessary to redirect some outgoing traffic to a different IP address from time to time ….

Recently the route to a mail server became unreachable from our mail server and we had to route traffic via an alternative relay server.

I achieved this using the trusty old iptables.

Here is the rule:

iptables -t nat -A OUTPUT -d <OriginalDestinationIPAaddress> -p tcp –dport <OriginalDestinationPort> -j DNAT –to-destination &ltNewDestinationIPAddress>:<NewDestinationPort>