iptables限制访问

常用命令

# 查看规则
iptables -L INPUT --line-numbers # 开放指定的端口
iptables -A INPUT -p tcp --dport 80 -j ACCEPT # 禁止指定端口
iptables -A INPUT -p tcp --dport 80 -j DROP # 拒绝所有端口
iptables -A INPUT -j DROP

限制ip

# 限制单个ip的所有端口访问
iptables -I INPUT -s 211.1.0.1 -j DROP # 封IP段所有端口访问
iptables -I INPUT -s 211.1.0.0/16 -j DROP
iptables -I INPUT -s 211.2.0.0/16 -j DROP
iptables -I INPUT -s 211.3.0.0/16 -j DROP # 封整个段所有端口访问
iptables -I INPUT -s 211.0.0.0/8 -j DROP

限制端口

# 限制9889端口 tcp访问
iptables -I INPUT -p tcp --dport 9889 -j DROP # 允许211.1.0.1 tcp访问9889端口
iptables -I INPUT -s 211.1.0.1 -p tcp --dport 9889 -j ACCEPT # 限制211.1.0.1 tcp访问9889端口
iptables -I INPUT -s 211.1.0.1 -p tcp --dport 9889 -j DROP

限制并发访问

# 限制211.1.0.1访问80端口的并发数不超过10
iptables -I INPUT -p tcp --dport 80 -s 211.1.0.1 -m connlimit --connlimit-above 10 -j REJECT

解除封印

# 解除所有
iptables -L INPUT # 解除单个(iptables -L --line-numbers 查看id)
iptables -D INPUT $ID

iptables限制访问的更多相关文章

  1. 使用nginx和iptables做访问权限控制(IP和MAC)

    之前配置的服务器,相当于对整个内网都是公开的 而且,除了可以通过80端口的nginx来间接访问各项服务,也可以绕过nginx,直接ip地址加端口访问对应服务 这是不对的啊,所以我们要做一些限制 因为只 ...

  2. Nginx+iptables屏蔽访问Web页面过于频繁的IP(防DDOS,恶意访问,采集器)

    通过分析nginx的日志来过滤出访问过于频繁的IP地址,然后添加到nginx的blockip.conf,并重启nginx 脚本如下: #!/bin/shnginx_home = /Data/app_1 ...

  3. iptables 限制访问规则

    iptables -I INPUT 1 -m state --state RELATED,ESTABLISHED -j ACCEPT把这条语句插在input链的最前面(第一条),对状态为ESTABLI ...

  4. 如何通过iptables代理访问内网

    场景 A机器能够联通内网机器,B机器能够联通A机器,但是访问不到内网机器,场景是希望通过A机器能够转发直接联通局域网内的其它机器 机器IP 内网为172.0.0.x/24 A机器为172.0.0.10 ...

  5. Linux iptables 应用控制访问SSH服务

    Title:Linux iptables 应用控制访问SSH服务  --2012-02-23 17:51 今天用到了以前从来没有用到过的,iptables控制访问,只允许外部访问SSH服务(22号端口 ...

  6. centos7 没有iptables服务 file or directory? 用secureCRT登录centos?

    cenetos7 采用systemd来管理服务 centos7 没有采用传统的iptables服务, 而是采用的firewalld 服务, 以及firewall-cmd 命令; 也可以采用传统的 ip ...

  7. iptables实现正向代理

    拓扑图 实现目标 内网用户通过Firewall服务器(iptables实现)访问外网http服务 配置 #iptables iptables -t nat -A POSTROUTING -i eth0 ...

  8. iptables实现反向代理

    拓扑图 实现目标 公网用户通过Firewall服务器(iptables实现)访问内网http服务 配置 #iptables iptables -t nat -A PREROUTING -p tcp - ...

  9. 为了解决linux配置Nginx 只能关闭防火墙才能访问的问题

    使用Nginx和iptables做访问权限控制(IP和MAC)     之前配置的服务器,相当于对整个内网都是公开的,而且,除了可以通过80端口的nginx来间接访问各项服务,也可以绕过nginx,直 ...

随机推荐

  1. Spring 中的事件机制

    说到事件机制,可能脑海中最先浮现的就是日常使用的各种 listener,listener去监听事件源,如果被监听的事件有变化就会通知listener,从而针对变化做相应的动作.这些listener是怎 ...

  2. rtsp 客户端请求视频的时候支持输入用户名和密码的格式

    rtsp://[<username>[:<password>]@]<server-address-or-name>[:<port>][/<path ...

  3. Sublime Text 3.2.1详细安装破解教程,附最新激活码license(全网独家可用有效)

    title: "Sublime Text 3.2.1详细安装破解教程,附最新激活码license(全网独家可用有效)" categories: soft tags: soft au ...

  4. 010 vue使用render方法渲染组件

    1.普通的组件渲染方式 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&qu ...

  5. spark跑YARN模式或Client模式提交任务不成功(application state: ACCEPTED)(转)

    不多说,直接上干货! 问题详情 电脑8G,目前搭建3节点的spark集群,采用YARN模式. master分配2G,slave1分配1G,slave2分配1G.(在安装虚拟机时) export SPA ...

  6. MYSQL报错:1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column

    1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'rpa ...

  7. python开发--Python实现延时操作的几种方式

    1. time.sleep 2. sched.scheduler 3. threading.Timer 4. 借助其他程序 celery redis延时队列 在日常的开发中,往往会遇到这样的需求,需要 ...

  8. IfcCircle

    An IfcCircle is a curve consisting of a set of points having equal distance from the center. NOTE  A ...

  9. Docker使用 - 容器

    查看容器 命令:docker  ps  [options] options有: -a:查看所有容器,包含不在运行中的(不带-a参数,是只显示运行中的容器) -q:只显示容器ID -s:多加一列来显示总 ...

  10. 让typecho支持PHP7

    在PHP7环境下新安装Typecho默认是使用Pdo_Mysql数据库引擎驱动 如果之前Typecho运行环境不是PHP7,后来才升级为PHP7的,那么,需要将你的Typecho数据库引擎修改为Pdo ...