Linux Netfilter discussions
 help / color / mirror / Atom feed
* Rewriting target IP and port on Linux with iptables or firewall-cmd
@ 2016-03-04 19:45 Alex Barylo
  2016-03-04 23:06 ` Harout Hedeshian
  2016-03-05  0:32 ` Sven-Haegar Koch
  0 siblings, 2 replies; 5+ messages in thread
From: Alex Barylo @ 2016-03-04 19:45 UTC (permalink / raw)
  To: netfilter

I have a server in a DC1 with a private IP, of say 10.10.10.10. This
IP is NAT'd to a public IP, say 216.58.219.10 in this way:

216.58.219.10:8090 -> 10.10.10.10:8089

I have a server in DC2 which knows about (and wants to connect to)
10.10.10.10:8089 but doesn't know about 216.58.219.10:8090 (long
story).

So I want to rewrite dest IP/port from 10.10.10.10:8089 to 216.58.219.10:8090.

This is what I tried:

# sysctl net.ipv4.ip_forward=1
# iptables -t nat -A PREROUTING -p tcp --dest 10.10.10.10 --dport 8089
-j DNAT --to 216.58.219.10:8090

...and it gives me this:

# iptables -L -t nat
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination
DNAT       tcp  --  anywhere             10.10.10.10       tcp
dpt:8089 to:216.58.219.10:8090

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

... and it doesn't work.

I see neither traffic to 10.x or to 216.x with tcpdump on the host in
DC2 where I'm trying to rewrite.

A side question: is there a way for me to see how traffic moves
between/through chains?

Any pointers are greatly appreciated.

Thanks,
Alex.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-03-08  0:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-04 19:45 Rewriting target IP and port on Linux with iptables or firewall-cmd Alex Barylo
2016-03-04 23:06 ` Harout Hedeshian
2016-03-05  0:32 ` Sven-Haegar Koch
2016-03-06 20:52   ` Pascal Hambourg
2016-03-08  0:25   ` Alex Barylo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox