Assume that we have a service only available in localhost (127.0.0.1/8) and we want to expose this port temporarily. Of course, you can use iptables for redirecting the port. But take care, this is not a simple DNAT because packets will not be evaluated by PREROUTING (-t nat) rules.
Another option is using an old-powerful Swiss knife tool: socat (github).
# binds public port to any local interface
socat TCP-LISTEN:<public_port>,fork TCP:127.0.0.1:<internal_port>
# binds only to an IP address
SOCAT_SOCKADDR=<interface_IP> socat TCP-LISTEN:<public_port>,fork TCP:127.0.0.1:<internal_port>
# binds to all interfaces:
socat TCP-LISTEN:1880,fork TCP:127.0.0.1:1880
# just for an IP address of one interface:
SOCAT_SOCKADDR=10.2.0.110 socat TCP-LISTEN:1880,fork TCP:127.0.0.1:1880
ssh USER@HOST "tcpdump -s 0 -U -n -w - -i NETIF FILTER" | "c:\Program Files\Wireshark\Wireshark.exe" -k -i -
# USER - remote user of the linux box
# HOST - host address of the remote linux box
# NETIF - network interface to snif in the remote linux box
# FILTER - (optional) rules for filtering traffic to capture
C:\Windows\System32\OpenSSH>ssh firstname.lastname@example.org "tcpdump -s 0 -U -n -w - -i eno2 udp and not port 53" | "c:\Program Files\Wireshark\Wireshark.exe" -k -i -
Let me present a rare use case of this useful trick. I use a QNAP NAS as a gateway in my home network, where I have 5 NICs. So it’s really useful to snif traffic remotly but I have no tcpdump packet in the system. What I did is use tcpdump as Docker container and finally the commands is like that.
# sniffing SIP traffic (port 5060) on interface eth0
# remote linux host (QNAP NAS) use SSH port 55222
# docker container is created and when work is done is removed
C:\Windows\System32\OpenSSH>ssh -p 55222 email@example.com "cd /share/Container/tcpdump && docker run --rm --net=host corfr/tcpdump -s 0 -U -n -w - -i eth0 not port 22 and port 5060" | "c:\Program Files\Wireshark\Wireshark.exe" -k -i -
When you are playing with Windows Hyper-V and you want to create a completely virtual internal network with private virtual machines inside your Windows 10 machine virtual switch are mandatory.
Then it’s the time to connect that virtual switch with the host machine using a virtual network interface. All those steps can be done using Hyper-V manager user interface, but you cannot control 100% of parameters like enable, or not, the NAT of the virtual internal network.
Of course, change “NATSwitch” for your switch name and “10.46.1.1” for the IP address of the host virtual network card. Finally “NATNetwork” is another arbitrary name for referring to the NAT rule, and “10.46.1.0/24” is the network address of the virtual internal host network.
In Windows 10 IP forwarding is not enabled and packets between interfaces are not routed. According to the Microsoft forums, you can enable IP forwarding (routing) using the following steps:
Go to Start and search on cmd or command. Right click on either cmd or command then select Run as administrator. At the command prompt type regedit. Navigate to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\Tcpip\Parameters\IPEnableRouter setting, right click and select Modify. Change 0 to 1 and exit the editor.
When your back at the command prompt type services.msc and navigate to the Routing and Remote Access service. Right click and select Properties. Change to Automatic and click on Start to start the service.
I had to research a long time until I found all this information, but in my case leverage my proofs of concepts to another level.
It’s just an IP spoofing protection which is by default enabled on Linux kernels. When it’s value is ‘1’ means that all IP address which are not directly routable and received form a network interface they are directly discarded.
So, if you want to scan a range of IP address in your LAN which not belong to that interface address space when packets from IP addresses are received they are going to be discarded by the kernel. So, take that into account when you have those “unusual” requirements.
It can be enable/disabled by all interfaces or just one:
When you want to discover LAN metadata without being part of that network. So, when you want to discover network address range, gateway, DNS IPs, DHCP server IPs, etc. this simple nmap parameter will help you so much.
# nmap --script broadcast-dhcp-discover
Starting Nmap 7.60 ( https://nmap.org ) at 2021-05-19 15:07 CEST
Pre-scan script results:
| Response 1 of 1:
| IP Offered: 192.168.1.127
| DHCP Message Type: DHCPOFFER
| Subnet Mask: 255.255.255.0
| Renewal Time Value: 4d00h00m00s
| Rebinding Time Value: 7d00h00m00s
| IP Address Lease Time: 8d00h00m00s
| Server Identifier: 192.168.1.1
| Router: 192.168.1.1
|_ Domain Name Server: 126.96.36.199, 188.8.131.52
WARNING: No targets were specified, so 0 hosts scanned.
Nmap done: 0 IP addresses (0 hosts up) scanned in 1.43 seconds
Simple shell script based on bash which monitor a host with command line ping. Just bash and ping are the unique dependencies. Only state change are going to be printed:
echo "$(date '+%Y-%m-%dT%H:%M:%S') - " + $STATE;
ping -c 4 $IP > /dev/null 2>&1
if [ "$?" = "0" ]; then
if [ "$STATE" = "offline" ];
if [ "$STATE" = "online" ];
Lately I bought a Surface Go for working specially as an agenda and for working outside home when I don’t have to work on technical stuff. At some point I considered the idea of working on that device remotely when I’m working with my desktop environment because it could be more comfortable specially because I have a bigger screen and keyboard for interacting with the content that I have on the tablet.
The first thing that I tried to do was enabling Remote Desktop Protocol on my Surface Go. But it was officially impossible because it has Windows 10 Home and the “Home” version doesn’t have this feature. BTW when you are not comfortable with this the best is googling little for finding any hack which allow me to enable the service. And yes, it exists and works really well.
You can find the project which hacks that in Windows 10 Home GitHub it’s called “rdpwrap” and if you want to know more about that go to next links:
After so much effort for getting RDP working on Windows 10 I discovered that RDP doesn’t work like Team Viewer, so you’re not going to control remote desktop while you can view what is happening in that remote session. This is not mandatory for me but in some cases it’s really useful. After some weeks I had to install Team Viewer for getting that feature working and I rediscovered that tool after some years without using it, and I was pleased to discover how good it works and how it improved after some years.
Then something inside me triggered the idea to look it up for an alternative to Team Viewer without so many restrictions and with a better free version. After trying some alternatives to Team Viewer I have to recommend Anydesk as an excellent and simple to use tool. And the most important thing, you don’t have to install anything in your Linux, Mac or Windows computer for using it. The only thing that you have to do is run the executable and use the auto-generated code for connecting to the remote system. I felt very good for those features and currently this is the option which I use for giving some support to friends remotely and for connecting to my Surface Go desktop remotely from my desktop computer.
As you can see this is not an exahustive revision, or comparsion of feautrues of all those three tools. But at the end of the day most of them allow you to do the same things but with slightly different procedures. BTW, the killer feature for me is something that I’ve got from “join.me” in the past, I mean use a tool for remote desktop control without having to install anything in the server and neither in the client part. I didn’t talk about “join.me” because it eats all my resources when I run it, and they focused the tool as a meeting tool and this is not anything that I want. Those extra features killed IMHO the best things that tool had in the past.