iptables 防火墙 只允许某IP访问某端口、访问特定网站
iptables 防火墙 只允许某IP访问某端口、访问特定网站
1.先备份iptables /var/tmp
需要开80端口,指定IP和局域网
下面三行的意思:
先关闭所有的80端口
开启ip段192.168.1.0/24端的80口
开启ip段211.123.16.123/24端ip段的80口
# iptables -I INPUT -s 192.168.1.0/24 -p tcp --dport 80 -j ACCEPT
# iptables
# service iptables restart
===============以下是转载================================================
以下是端口,先全部封再开某些的IP
iptables -I INPUT -s 192.168.1.0/24 -p tcp --dport 9889 -j ACCEPT
如果用了NAT转发记得配合以下才能生效
iptables -I FORWARD -s 192.168.1.0/24 -p tcp --dport 80 -j ACCEPT
常用的iptables -I Filter -m mac --mac-source 00:0F:EA:25:51:37 -j DROP
iptables -I Filter -m mac --mac-source 00:0F:EA:25:51:37 -p tcp --dport 25 -j ACCEPT
iptables -I PFWanPriv -d 192.168.100.2 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 1723 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.100.2:1723
iptables -t nat -A PREROUTING -p udp --dport 500 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.100.2:500
iptables -I PFWanPriv -p tcp --dport 21 -d 192.168.100.200 -j ACCEPT
iptables -A Filter -p udp --dport 53 -j ACCEPT
iptables -A Filter -d www.3322.org -j ACCEPT
iptables -A Filter -j DROP
开放一些端口,其它都封闭
iptables -A Filter -p tcp --dport 25 -s 192.168.100.200 -j ACCEPT
iptables -A Filter -p tcp --dport 110 -s 192.168.100.200 -j ACCEPT
iptables -A Filter -p udp --dport 53 -j ACCEPT
iptables -A Filter -p tcp -m multiport --destination-port 22,53,80,110 -s 192.168.20.3 -j REJECT
连续端口
iptables -A Filter -p tcp --source-port 2:80 -s 192.168.20.3 -j REJECT
指定时间上网
iptables -A Filter -m time --timestart 12:00 --timestop 13:00 --days Mon,Tue,Wed,Thu,Fri,Sat,Sun -j ACCEPT
禁止多个端口服务
iptables -t nat -A PREROUTING -i $INTERNET_IF -d $INTERNET_ADDR -j DNAT --to-destination 192.168.0.1
将WAN口8000端口NAT到192。168。100。200的80端口
iptables -t nat -A PREROUTING -p tcp --dport 110 -d $INTERNET_ADDR -j DNAT --to-destination 192.168.100.200:110
禁止
iptables -A Filter -j DROP
禁用BT配置
iptables -A Filter -p udp --dport ! 53 -j DROP
iptables -A Filter -d 218.18.95.0/24 -j DROP
iptables -I Filter -m mac --mac-source 00:0A:EB:97:79:A1 -j DROP
iptables -I Filter -m mac --mac-source 00:0A:EB:97:79:A1 -p tcp --dport 110 -j ACCEPT
禁用MSN配置
iptables -A Filter -p tcp --dport 1863 -j DROP
iptables -A Filter -p tcp --dport 80 -d 207.46.110.0/24 -j DROP
只允许PING 202。96。134。133 其它公网IP都不许PING
iptables -A Filter -p icmp -j DROP
iptables -I Filter -m mac --mac-source 00:20:18:8F:72:F8 -j DROP
某个IP地址的PING:
禁止iptables –A Filter -p tcp -s 192.168.0.1 --dport 80 -j DROP
iptables -A Filter -p tcp -s 192.168.0.1 --dport 1000 -j ACCEPT
禁止iptables -A Filter -p tcp -s 10.10.10.253 --dport 80 -j ACCEPT
禁止某个MAC地址的某个端口服务
禁止某个MAC地址访问internet:
禁止iptables –A Filter –p icmp –s 192.168.0.1 –j DROP
iptables 防火墙 只允许某IP访问某端口、访问特定网站的更多相关文章
- Iptables 防火墙开放常见的22,53,80端口
用iptables防火墙 iptables -F # 允许包从22端口进入 iptables -A INPUT -p tcp --dport 22 -j ACCEPT # 允许从22端口进入的包返回 ...
- iptables防火墙与日志系统配合使用 监控服务器特点端口的防问源IP
/etc/sysconfig/iptables -A INPUT -p tcp --dport 80 -j LOG --log-level 5 --log-prefix "PORT_80:& ...
- SSH有端口映射功能(访问本地端口=访问远程端口)
大部分SSH连接软件都有SSH通道转发功能,就是用这个实现的. 如果Delphi在代码上实现的话,用libSSH 或者 SecureBridge都可以. 代码基本不用帖,思路给大家讲一下吧. SSH有 ...
- elasticsearch 外网访问9200端口访问
可以访问127.0.0.1:9200,但不能访问 公网IP:9200 后面ip就是127.0.0.1的局域网ip,如何解决? 修改配置文件 config/elasticsearch.yml netwo ...
- iptables防火墙相关命令详解
前提基础: 当主机收到一个数据包后,数据包先在内核空间中处理,若发现目的地址是自身,则传到用户空间中交给对应的应用程序处理,若发现目的不是自身,则会将包丢弃或进行转发. iptables实现防火墙功能 ...
- iptables中规则的关系——以只允许某些IP段访问为例
最近遇到一个问题:服务器被全球的IP频繁试图通过ssh登录. 于是想到通过iptables防火墙限制访问,达到:仅允许指定ip段访问ssh服务(22端口). 关于iptables添加规则的文章有很多, ...
- iptables只允许指定ip地址访问指定端口
首先,清除所有预设置 iptables -F#清除预设表filter中的所有规则链的规则 iptables -X#清除预设表filter中使用者自定链中的规则 其次,设置只允许指定ip地址访问指定端口 ...
- linux下通过iptables只允许指定ip地址访问指定端口的设置方法
这篇文章主要介绍了linux下通过iptables只允许指定ip地址访问指定端口的设置方法,需要的朋友可以参考下. 首先,清除所有预设置 iptables -F#清除预设表filter中的所有规则链的 ...
- iptables只允许指定ip访问本机的指定端口
首先,清除所有预设置 iptables -F 其次,设置只允许指定ip地址访问指定端口 1.在tcp协议中,禁止所有的ip访问本机的1521端口. iptables -I INPUT -p tcp - ...
随机推荐
- 【C++】String类中的运算符重载
模块化设计: 头文件: <span style="font-size:18px;"> #ifndef operator_operator_h #define opera ...
- SQL Server loop - how do I loop through a set of records
SQL Server loop - how do I loop through a set of records By using T-SQL and cursors like this : DECL ...
- DBS-Oracle:表的连接查询
ylbtech-DBS-Oracle:表的连接查询 链接查询是指基于两个或两个以上表或试图的查询.在实际应用中,查询单个表可能无法满足应用程序的实际需求(例如显示雇员的部门名称以及雇员名),在这种情况 ...
- 剑指offer——02替换空格(Python3)
思路:Python列表中实现字符串的替换,涉及到频繁的插入操作,在数据结构中线性表分为顺序表和链表,顺序表的适合频繁的查询,链表适合频繁的插入和删除.综上所述,本题使用链表来实现. 我们从字符串的后面 ...
- 解决问题方法:没有设置对象,app.Config没有配置
- ASP.NET在IIS 5/6上的运行模型(ISAPI)
IIS 5.X中的ASP.NET 实现了Web Server和ASP.NET App的分离. IIS作为Web Server运行在InetInfo.exe进程上.该进程是非托管的本地进程. ASP.N ...
- 详解循环神经网络(Recurrent Neural Network)
本文结构: 模型 训练算法 基于 RNN 的语言模型例子 代码实现 1. 模型 和全连接网络的区别 更细致到向量级的连接图 为什么循环神经网络可以往前看任意多个输入值 循环神经网络种类繁多,今天只看最 ...
- Book 树状数组 小结
差不多花了10天学树状数组,是照着这篇博客做的题目,还差几道---------- http://blog.csdn.net/chenguolinblog/article/details/9916229 ...
- 路飞学城Python-Day39(第四模块复习题)
并发编程 一.简答题 1,简述计算机操作系统的中断的作用 由于cpu本身一次只能执行一个程序,操作系统提供的中断机制使得cpu能够实现不断的在各个程序间进行切换,给人的感觉就是多个程序同时执行 为什么 ...
- 谈 instanceof 和 typeof 的实现原理
typeof: js 在底层存储变量的时候,会在变量的机器码的低位1-3位存储其类型信息