[ 总结 ] 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 ...
随机推荐
- 配置cas可外网访问
把应用程序tomcat下的conf下的context.xml里配置内容修改 如把: D:\apache-tomcat-APP\conf\context.xml <Resource name=&q ...
- HDU 4436 str2int(后缀自动机)(2012 Asia Tianjin Regional Contest)
Problem Description In this problem, you are given several strings that contain only digits from '0' ...
- UVA 11884 A Shooting Game(记忆化搜索)
A and B are playing a shooting game on a battlefield consisting of square-shaped unit blocks. The bl ...
- PhpStorm 配置数据库
点击软件右边的 Database
- lintcode-45-最大子数组差
45-最大子数组差 给定一个整数数组,找出两个不重叠的子数组A和B,使两个子数组和的差的绝对值|SUM(A) - SUM(B)|最大. 返回这个最大的差值. 注意事项 子数组最少包含一个数 样例 给出 ...
- springmvc项目搭建四-基于前端框架完善页面的数据显示
上一篇把前端框架先放上去了,现在开始前后端进行交互,对数据进行显示. 效果如图所示...中间经历了数据显示不上去的问题,是对于spring的注解了解不够,问题及其解决可以参照上一篇问题处理... 目前 ...
- C# 托盘图标闪烁
在用户正在登录QQ或者使用Firemail邮件系统自动收取邮件的时候,托盘图标会闪动提示用户正在运行的任务.闪动图标可以使用定时切换托盘图标的方式实现,托盘图标可以从ImageList控件中获取.在I ...
- Eclipse中的引用项目报Could not find *.apk!解决办法
百度上很多关于Could not find *.apk!这种编译报错的解决帖子,但是笔主在这里主要说一下在 引用工程项目的场景 下报这个错误消息的问题(不影响本项目的正常编译运行!). 笔主刚从谷歌上 ...
- ACM模板~求第k短路 ~~~A*+Dijkstra
#include <map> #include <set> #include <cmath> #include <ctime> #include < ...
- hdu Shell Necklace 5730 分治FFT
Description Perhaps the sea‘s definition of a shell is the pearl. However, in my view, a shell neckl ...