Score:0

How to setup iptables port forwarding?

br flag

I want to access a ssh Server via a NAT. SSH Server Lan: 192.168.69.2:22 connected on interface wg0 (wireguard) local IP on interface wg0: 192.168.69.1 public IP is directly connected to eth0.

my current configuration:

sysctl -w net/ipv4/ip_forward=1
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
/sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 2024 -j DNAT --to-destination 192.168.69.2:22

When I then try to connect to ssh root@publicIP -p 2024 it doesn't connect. Connection timed out. local connection to ssh [email protected] -p 22 works.

But if I forward port 2024 to the local IP it works:

/sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 2024 -j DNAT --to-destination 192.168.69.1:22

Any suggestion on what I did wrong or which rules I have to add?

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.