linux iptables 備忘

  1. 內網機器上網

    iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j SNAT -to-source 10.0.0.1

    or

    iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE


  2. 外部到內部映射

    端口映射

    iptables -t nat -A PREROUTING -d 10.0.0.1 -p tcp --dport 80 -j DNAT --to-destination 192.168.1.100:80     

    IP 1v1

    iptables -t nat -A PREROUTING -d 10.0.0.2 -j DNAT --to-destination 192.168.1.100

    iptables -t nat -A POSTROUTING -s 192.168.1.100 -j SNAT --to-source 10.0.0.2

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章