Friday 6 April 2018

How to specify particular source address & port in iptables

How to specify particular source address & port in iptables:


  • Source ip (-s)
    • -s, --source address[/mask][,...]
  • Destination (-d)
    • -d, --destination address[/mask][,...]
  • Source Port:
    • --source-port,--sport [!] port[:port]
  • Destination port:
    • --destination-port,--dport [!] port[:port]
  • protocol
    • -p <protocol name, tcp, udp, icmp> 

Example:

iptables -t nat -A PREROUTING -p tcp -s 192.168.1.99 --sport 58902 -d 173.223.52.123 --dport 80 -j DNAT --to-destination 192.168.1.254:80

No comments:

Post a Comment