0

In our network I have 3 clients: A, B and C (connected to the same router). I tried to redirect the traffic that arrive to B on port 4440 to C on port 4441 using iptables-legacy

  1. simulating port listener on B: I typed nc -l 4440
  2. simulating port listener on C: I typed nc -l 4441
  3. on B: bog@bog-desktop:~$ sudo iptables-legacy -t nat -A PREROUTING -i eno1 -p tcp --dport 4440 -j DNAT --to-destination 192.168.1.14:4441

then from A i tried to telnet to B on port 4440: telnet 192.168.1.B 4440 (I use B instead of the number just to make it easier) and after a while I get the message Connection timed out.

Then I print again my chains:

bog@bog-desktop:~$ sudo iptables-legacy -L -v --line-numbers -n -t nat
Chain PREROUTING (policy ACCEPT 18 packets, 5949 bytes)
num   pkts bytes target     prot opt in     out     source               destination         
1        2   120 DNAT       tcp  --  eno1   *       0.0.0.0/0            0.0.0.0/0            tcp dpt:4440 to:192.168.1.14:4441

Chain INPUT (policy ACCEPT 18 packets, 5949 bytes)
num   pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 7 packets, 1941 bytes)
num   pkts bytes target     prot opt in     out     source               destination         

Chain POSTROUTING (policy ACCEPT 9 packets, 2061 bytes)
num   pkts bytes target     prot opt in     out     source               destination 

and I realize that a couple of pkgs ave arrived to the PREROUTING chain but haven't received them on the C machine.

But telnet 192.168.1.C 4441 works just fine PS, I also enabled forwarding on B with sudo sysctl -w net.ipv4.ip_forward=1

I couldn't solve my problem with any of articles I have found online.

4
  • doesn't work because replies from C skip B. A sees packets from C it doesn't know about.
    – A.B
    May 10, 2021 at 22:55
  • Pardon, I didn't understand.
    – Bog Alt
    May 12, 2021 at 5:54
  • Can't tell it better than what I wrote. You assume C didn't receive anything. The only way to validate this hypothesis is to run tcpdump on C and double check.
    – A.B
    May 12, 2021 at 7:18
  • Thanks for your reply. I will try.
    – Bog Alt
    May 13, 2021 at 10:56

0

You must log in to answer this question.

Browse other questions tagged .