Skip to content

Instantly share code, notes, and snippets.

@umardx
Last active June 27, 2023 14:02
Show Gist options
  • Save umardx/de075efb6aa923a3ea296cf40bb672aa to your computer and use it in GitHub Desktop.
Save umardx/de075efb6aa923a3ea296cf40bb672aa to your computer and use it in GitHub Desktop.
Assume there are two servers 192.168.1.1 as the tester, and 172.16.8.1 as the target. We will test which open inbound ports on the target server.

Assume there are two servers 192.168.1.1 as the tester, and 172.16.8.1 as the target. We will test which open inbound ports on the target server.

Firewall Case

PREROUTE all traffic from IP 192.168.1.1/32 to port 127.0.0.1:80

iptables -t nat -A PREROUTING -s 192.168.1.1/32 -p tcp -m tcp --dport 80 -j RETURN
iptables -t nat -A PREROUTING -s 192.168.1.1/32 -p tcp -j DNAT --to-destination :80

Log everything from IP 192.168.1.1/32

iptables -I INPUT -s 192.168.1.1/32 -p tcp -m tcp -m state --state NEW -j LOG --log-level 1 --log-prefix "New Connection "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment