禁止某ip访问

  1. 使用firewall配置,通过添加富规则(rich rules)来实现
    firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address="8.147.170.200" drop'
    firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address="38.147.170.23" drop'
    firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address="38.147.170.124" drop'
    firewall-cmd --reload

  2. 使用iptables配置

  • 保存备份iptables规则iptables-save > /etc/iptables.rules
  • 设置规则
    iptables -A INPUT -s 8.147.170.200 -j DROP
    iptables -A INPUT -s 38.147.170.23 -j DROP
    iptables -A INPUT -s 38.147.170.124 -j DROP
  • 将规则写入/etc/iptables.rules
    echo "-A INPUT -s 8.147.170.200 -j DROP" >> /etc/iptables.rules
    echo "-A INPUT -s 38.147.170.23 -j DROP" >> /etc/iptables.rules
    echo "-A INPUT -s 38.147.170.124 -j DROP" >> /etc/iptables.rules
posted @   武胜造纸农  阅读(15)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
点击右上角即可分享
微信分享提示