Score:0

Port forwarding with iptables prerouting not work

cg flag

I have 3 server

  • server A: 5.161.x.x
  • server B: 193.151.x.x
  • server C: 195.96.x.x

I want to forward all traffic from server B and C to server A ,i forwarded Server B to server A with this command:

sysctl net.ipv4.ip_forward=1
iptables -t nat -A PREROUTING -p tcp --dport 442:65533 -j DNAT --to-destination 5.161.x.x
iptables -t nat -A POSTROUTING -j MASQUERADE

its work but when i want forward traffic from server C to A with same command its not work.

The point is that it works to any address I forward to, but it doesn't work when I forward to server A

  • i dont need port 1-442. just need 442-65533
  • in server A port 443 have page and i test with this page

iptables -t nat -v -L PREROUTING -n --line-number image

eltrai avatar
my flag
Please clarify how are server B and C different. Are they both connected to server A directly?
Aref Solaimany avatar
cg flag
There is no difference between these two servers. Both of them use ubuntu. (only the data centers are different).Yes, they are connected (I checked again with the `ping` command)
eltrai avatar
my flag
Can you post a tcpdump from both showing the traffic?
Aref Solaimany avatar
cg flag
how to tcpdump? `sudo tcpdump -D`?
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.