Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
At that point, connection fails on the remote. It appears that the remote (184.57.114.221) is being routed to port 3389 on the Windows computer (2nd output line, above), but still no connection. I've turned off the firewall on the Windows computer.
> tcpdump -tttt -ln -i eth1 tcp port 1912 or tcp port 3389
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 262144 bytes
2019-03-26 04:17:38.242129 IP 184.57.114.221.62961 > 192.168.0.2.1912: Flags [S], seq 3350291930, win 8192, options [mss 1460,nop,wscale 2,nop,nop,sackOK], length 0
2019-03-26 04:17:38.242153 IP 184.57.114.221.62961 > 192.168.0.58.3389: Flags [S], seq 3350291930, win 8192, options [mss 1460,nop,wscale 2,nop,nop,sackOK], length 0
As you can see, the outgoing packet to 192.168.0.58:3389 still has the original source address (187.57.114.221). That means the Windows computer won't be routing its relpies through 192.168.0.2, but rather use the default gateway (the SonicWall) which, since it's not expecting replies from 192.168.0.58, will just drop the packets.
The POSTROUTING rule isn't catching packets from external hosts going to the Windows system, since it was only designed to handle the 2nd hairpin scenario (local PCs connecting to the Windows host via 192.168.0.2). Try adding this rule:
Holy Firewall, Batman! That worked! You're a genius! I'll have to study this some more and incorporate it with my existing firewall, and route the other workstations in the same way.
To recap for the benefit of others: I want to do this because the new Sonicwall firewall/router/gateway apparently does not alert or counter-measure on brute-force attempts on RDP and VNC ports. I'm not certain they do so for their VPN either. I'm discussing this on the Sonicall forum. My 192.168.0.2 server has a counter-measure script to detect and block such attacks. Hence this thread.
As a stripped-down iptables script, I've ended up with the following:
Code:
# Flush existing ruleset:
iptables -F
iptables -t nat -F
# Set reasonable policy defaults (that is, these are "reasonable" for an exposed firewall; you
# may decide that an input policy of ACCEPT is, well, acceptable in this particular scenario):
# iptables -P INPUT DROP
# iptables -P FORWARD DROP
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
# You really don't want to stop loopback traffic with a DROP policy:
iptables -A INPUT -i lo -j ACCEPT
# Allow existing sessions for both local and routed traffic:
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
# If the INPUT policy is indeed DROP, add rules for relevant local services here; the example below handles SSH:
# iptables -A INPUT -p tcp --dport 22 -m state --STATE NEW -j ACCEPT
# Forward TCP port 1912 to 192.168.0.58:3389
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 1912 -j DNAT --to-destination 192.168.0.58:3389
# Allow the forwarded packet through; remember to reference the translated IP address and portnumber, not the NATed ones:
iptables -A FORWARD -i eth1 -d 192.168.0.58 -p tcp --dport 3389 -j ACCEPT
# Preserve return path by NATing behind 192.168.0.2 (eth1):
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -d 192.168.0.58 -p tcp --dport 3389 -j SNAT --to-source 192.168.0.2
# Catch packets from external hosts going to the Windows system
iptables -t nat -A POSTROUTING -o eth1 -d 192.168.0.58 -p tcp --dport 3389 -j SNAT --to-source 192.168.0.2
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.