[ 总结 ] web server iptables 简单配置
[root@server ~]# iptables -F
[root@server ~]# iptables -X
[root@server ~]# iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT # 不允许服务器主动建立新连接
[root@server ~]# iptables -A INPUT -p tcp -m multiport --dport , -m state --state NEW -j ACCEPT # 允许22,80端口的连接和监听
[root@server ~]# iptables -A OUTPUT -p tcp -m multiport --sport 22,80 -j ACCEPT # 允许客户端访问22,80端口
[root@server ~]# iptables -P INPUT DROP # 默认禁止
[root@server ~]# iptables -P FORWARD DROP # 默认禁止
[root@server ~]# iptables -P OUTPUT DROP # 默认禁止
[root@server ~]# iptables -A INPUT -p udp --sport -j ACCEPT # 允许dns服务
[root@server ~]# iptables -A OUTPUT -p udp --dport -j ACCEPT # 允许dns服务
[root@server ~]# iptables -A INPUT -p icmp -j ACCEPT # 开启 icmp协议
[root@server ~]# iptables -A OUTPUT -p icmp -j ACCEPT # 开启 icmp协议
[root@server ~]# service iptables save # 保存配置
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
[root@server ~]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
对应一般的简单web服务器基本够用,当然ssh端口肯定会修改,以上命令也进行调整。如果要禁止别人ping服务器,建议进行以下设置:
临时生效:echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
永久生效:
[root@server ~]# echo "net.ipv4.icmp_echo_ignore_all = 1" >> /etc/sysctl.conf
[root@server ~]# sysctl -p
# Generated by iptables-save v1.4.7 on Mon Mar ::
*filter
:INPUT DROP [:]
:FORWARD DROP [:]
:OUTPUT DROP [:]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m multiport --sports , -m state --state NEW -j ACCEPT
-A INPUT -p udp -m udp --sport -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A OUTPUT -p tcp -m multiport --sports 22,80 -j ACCEPT
-A OUTPUT -p udp -m udp --dport -j ACCEPT
-A OUTPUT -p icmp -j ACCEPT
COMMIT
# Completed on Mon Mar ::
可以直接复制上面iptables配置到vim /etc/sysconfig/iptables 然后重启iptables
关于转发:
因为非root用户不能监听1024以下端口,所以经常使用iptables来进行转发的工作:
iptables -t nat -A PREROUTING -p tcp --dport -j REDIRECT --to-port 8080 # 8080端口映射到80端口
iptables -t nat -A PREROUTING -p tcp --dport -j DNAT --to-destination 192.168.2.11:8080 # 192.168.2.11的8080端口映射到80端口。可用于两台主机转发
[ 总结 ] web server iptables 简单配置的更多相关文章
- iptables简单配置
iptables简单配置 分类: Linux 安全2010-10-20 16:56 4241人阅读 评论(0) 收藏 举报 input防火墙tcpfilterubuntuservice # iptab ...
- iptables 简单配置
通过命令 netstat -tnl 可以查看当前服务器打开了哪些端口 Ssh代码 netstat -tnl 查看防火墙设置 Ssh代码 iptables -L -n 开放 ...
- Linux iptables简单配置
#!/bin/sh#modprobe ipt_MASQUERADEmodprobe ip_conntrack_ftpmodprobe ip_nat_ftpiptables -Fiptables -t ...
- JetBrains IDEA Web开发简单配置
很早前因为使用了一年的MyEclipse,不想更换其他的IDE工具,是因为各项配置,以及快捷键等.前段时间更换了IDEA工具,初步了解了一些功能,包括快捷,调试,配置,都很优于MyEclipse.但是 ...
- PHP内置的Web Server的使用
自PHP5.4之后 PHP内置了一个Web 服务器. 让我们来看看php Web Server的简单使用: 启动php Web Server php -S localhost:8080 通过 php ...
- 释放SQL Server占用的内存 .Net 读取xml UrlReWriter 在web.config中简单的配置
释放SQL Server占用的内存 由于Sql Server对于系统内存的管理策略是有多少占多少,除非系统内存不够用了(大约到剩余内存为4M左右),Sql Server才会释放一点点内存.所以很多 ...
- Web Server Jexus配置及使用
Web Server Jexus配置及使用 一.jexus概念: Jexus 即 Jexus Web Server,简称JWS,是Linux平台上的一款ASP.NET WEB服务器,是 Linux. ...
- Jexus-5.6.3使用详解、Jexus Web Server配置
一.Jexus Web Server配置 在 jexus 的工作文件夹中(一般是“/usr/jexus”)有一个基本的配置文件,文件名是“jws.conf”. jws.conf 中至少有 Site ...
- Unity3d Web Player 与server端联网配置
针对Unity3d Web Player 的server端联网配置写一随笔咯. 以SmartFoxServer2X官方的Unity3d Example ”tris“为例,部署好服务器之后,在Unit ...
随机推荐
- Good Time 冲刺 三
第三天 日期:2018.6.16 一.今日完成任务情况及遇到的问题 王怡镔:继续在学习微信小程序的设计,完善设计发现页面,开始编写发现页面 于鑫宇:配合黄鹤的工作,学习端口相关知 胡雅馨:继续改进优化 ...
- 【EasyNetQ】- 控制队列名称
在为队列生成名称时,EasyNetQ的默认行为是使用消息类型名称并将其附加到订阅ID.例如PartyInvitation,命名空间中的消息类型EasyNetQ.Tests.Integration将使用 ...
- 【历史】- Unix时代的开创者Ken Thompson
自图灵奖诞生以来,其获得者一直都是计算机领域的科学家与学者,而在所有这些界的图灵奖中只有唯一的一届有个例外,那就是Ken Thompson与Dennis M. Ritchie,他们都是计算机软件工程师 ...
- tomcat 服务添加到系统服务
tomcat: 设置环境变量: CATALINA_HOME: tomcat路径 列如:D:\apache-tomcat-8.5.24 打开命令窗口,进入到tomcat/bin目录下 执行service ...
- php array_merge和“+”的区别和使用《细说php2》
php array_merge和“+”的区别和使用
- [剑指Offer] 41.和为S的连续正数序列
题目描述 小明很喜欢数学,有一天他在做数学作业时,要求计算出9~16的和,他马上就写出了正确答案是100.但是他并不满足于此,他在想究竟有多少种连续的正数序列的和为100(至少包括两个数).没多久,他 ...
- [LeetCode] 56. Merge Intervals(vector sort)
/** * Definition for an interval. * struct Interval { * int start; * int end; * Interval() : start(0 ...
- 【题解】ZJOI2017仙人掌
感觉这题很厉害啊,虽然想了一天多但还是失败了……(:д:) 这题首先注意到给定图中如果存在环其实对于答案是没有影响的.然后关键之处就在于两个 \(dp\) 数组,其中 \(f[u]\) 表示以 \(u ...
- [Usaco2005 Dec]Cleaning Shifts 清理牛棚 (DP优化/线段树)
[Usaco2005 Dec] Cleaning Shifts 清理牛棚 题目描述 Farmer John's cows, pampered since birth, have reached new ...
- Welcome to ShangHai <码农上漂记>
来上海这边快三周了,一切都还算顺利,多亏了朋友们的帮助,要不就得街头打地铺了.对于上海这样的大都市,年轻的我们都想挤一挤,凑凑热闹,实现自己的小小抱负.然而不是每个人都混的起的.以前的我还总想着来大城 ...