heiher / natmap

TCP/UDP port mapping for full cone NAT
MIT License
1.38k stars 103 forks source link

HevIFwd: Add support for iptables forwarding #61

Open MikeWang000000 opened 6 months ago

MikeWang000000 commented 6 months ago

iptables implementation for #51 .

Example of usage:

sudo natmap -m iptables -s turn.cloudflare.com -h a.co -t 127.0.0.1 -p 80

Check iptables rules:

sudo iptables -t nat --list-rules
-P PREROUTING ACCEPT
-P INPUT ACCEPT
-P OUTPUT ACCEPT
-P POSTROUTING ACCEPT
-N NATMAP
-A PREROUTING -j NATMAP
-A OUTPUT -j NATMAP
-A NATMAP -d 10.0.1.100/32 -p tcp -m tcp --dport 11609 -j DNAT --to-destination 10.0.1.100:80

The rule will be removed automatically when NATMap exits normally (e.g. Ctrl-C, SIGTERM).