I needed to write a iptables rule to block outbound traffic to a specific host here.
Now I need to write a similar rule which will not block the entire host but just a single port to a host.
The rule is very simlar to the previously state but with the port flag, see below.
iptables -A OUTPUT -p tcp --dport 8080 -d 10.1.2.6 -j DROP
I started a windows vm on my network which I needed RDP access to, I didnt know its IP address. I could have used Nmap but it was not installed so I decided to use Netcat instead.
I have not had a chance to test it but network scanned my entire subnet in 2.5 minutes.
for i in `seq 1 254`; do nc -z -w1 192.168.0.$i 3389; if [ $? -eq "0" ]; then echo "192.168.0.$i - $?";fi;done
So the above command with scan each IP in the submit and probe port 3389 (RDP) to see if its open, if it is it will display the IP.