My scenario:
I have two machines:
1. 192.168.1.1
2. 192.168.1.2
Machine 2 has a ssh server and I created a tunnel in machine 1 such as:
It works fine.I tested via
Now I want to send any traffic to 127.0.0.1:7777 Not a one application, All of my traffic.
Then my tunnel send my packets to 192.168.1.1 My algorithm is: IF DST PORT IS NOT 7777 THEN ROUTE MY TRAFFIC TO 127.0.0.1:7777 ELSE DO NOT ROUTE TO 127.0.0.1:7777 I used the following rule, but it didn't work: iptables -t nat -A PREROUTING -i enp0s31f6 -p udp ! --dport 7777 -j REDIRECT --to-ports 7777 How can I implement it?
ssh -CfND 7777 mohsen@192.168.1.2 -4
I ran above command in machine 1 It works fine.I tested via
firefox
Now I want to send any traffic to 127.0.0.1:7777 Not a one application, All of my traffic.
Then my tunnel send my packets to 192.168.1.1 My algorithm is: IF DST PORT IS NOT 7777 THEN ROUTE MY TRAFFIC TO 127.0.0.1:7777 ELSE DO NOT ROUTE TO 127.0.0.1:7777 I used the following rule, but it didn't work: iptables -t nat -A PREROUTING -i enp0s31f6 -p udp ! --dport 7777 -j REDIRECT --to-ports 7777 How can I implement it?
Asked by PersianGulf
(11308 rep)
Apr 15, 2025, 03:47 AM
Last activity: Apr 15, 2025, 01:16 PM
Last activity: Apr 15, 2025, 01:16 PM