Iptables开启及关闭 IP和端口

  1. 允许、禁止IP访问

     # 允许
     iptables -A INPUT -s [ip] -j ACCEPT
     service iptables save
     # 禁止
     iptables -A INPUT -s [ip] -j DROP
     service iptables save
    
  2. 允许、禁止端口访问

     # 允许
     iptables -A INPUT -p tcp --dport [端口] -j ACCEPT
     iptables -A OUTPUT -p tcp --sport [端口] -j ACCEPT
     service iptables save
     # 禁止
     iptables -A INPUT -p tcp --dport [端口] -j DROP
     iptables -A OUTPUT -p tcp --sport [端口] -j DROP
     service iptables save
    

results matching ""

    No results matching ""