Linux 上关于iptables
yum install -t iptables
[root@iZ28fg6zc2zZ ~]# service iptables start
iptables: No config file. [WARNING]
[root@iZ28fg6zc2zZ ~]# iptables -F [root@iZ28fg6zc2zZ ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ] [root@iZ28fg6zc2zZ ~]# 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 ]
[root@iZ28fg6zc2zZ ~]#
. iptables -A OUTPUT -p tcp -m tcp --sport 6379 -j ACCEPT
添加6379这个端口 . /etc/init.d/iptables save . cat /etc/sysconfig/iptables
看你添加的端口存在不
. service iptables restart
存在,执行这个命令 看博主的解释:
12 - 只修改/etc/sysconfig/iptables 使其生效的办法是修改好后先service iptables restart,然后才调用/etc/rc.d/init.d/iptables save,
13 - 因为/etc/rc.d/init.d/iptables save会在iptables服务启动时重新加载,要是在重启之前直接先调用了/etc/rc.d/init.d/iptables save那么你
14 - 的/etc/sysconfig/iptables 配置就回滚到上次启动服务的配置了,这点必须注意!!!
参考资料:http://www.linuxidc.com/Linux/2012-03/56066.htm
下面粘出博主的/ect/sysconfig/iptables的配置
- /etc/sysconfig/iptables文件配置如下:
- # Generated by iptables-save v1.4.7 on Fri Mar ::
- *filter
- :INPUT DROP [:]
- :FORWARD DROP [:]
- :OUTPUT DROP [:]
- -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
- #ping使用的端口
- -A INPUT -p icmp -j ACCEPT
- -A INPUT -i lo -j ACCEPT
- -A INPUT -s 127.0.0.1/ -d 127.0.0.1/ -j ACCEPT
- -A INPUT -s 192.168.2.200/ -d 192.168.2.200/ -j ACCEPT
- #允许服务器自己的SSH(对外部请求来说服务器是目标所以使用--dport)
- -A INPUT -p tcp -m tcp --dport -j ACCEPT
- #80端口不用说了吧,服务器网站访问端口
- -A INPUT -p tcp -m tcp --dport -j ACCEPT
- -A INPUT -p tcp -m tcp --dport -j ACCEPT
- -A INPUT -p tcp -m tcp --dport -j ACCEPT
- -A INPUT -p tcp -m tcp --dport -j ACCEPT
- -A FORWARD -j REJECT --reject-with icmp-host-prohibited
- #53端口是DNS相关,TCP和UDP都要配置
- -A INPUT -p tcp -m tcp --dport -j ACCEPT
- -A INPUT -p udp -m udp --dport -j ACCEPT
- #ping使用的端口
- -A OUTPUT -p icmp -j ACCEPT
- -A OUTPUT -s 127.0.0.1/ -d 127.0.0.1/ -j ACCEPT
- -A OUTPUT -s 192.168.2.200/ -d 192.168.2.200/ -j ACCEPT
- #允许服务器SSH到其他机器(使用外部端口就使用--dport)
- -A OUTPUT -p tcp -m tcp --dport -j ACCEPT
- #允许服务器自己的SSH(自已为源输出就使用--sport)
- -A OUTPUT -p tcp -m tcp --sport -j ACCEPT
- #访问外部网站80端口(使用外部端口就使用--dport)
- -A OUTPUT -p tcp -m tcp --dport -j ACCEPT
- #如果服务器需要访问外部网站,那么OUTPUT也需要配置53端口(使用外部端口就使用--dport)
- -A OUTPUT -p tcp -m tcp --dport -j ACCEPT
- -A OUTPUT -p udp -m udp --dport -j ACCEPT
- #如果有访问外部邮箱,那么打开邮箱相关端口(使用外部端口就使用--dport)
- -A OUTPUT -p tcp -m tcp --dport -j ACCEPT
- -A OUTPUT -p tcp -m tcp --dport -j ACCEPT
- -A OUTPUT -p tcp -m tcp --dport -j ACCEPT
- #服务器网站访问端口(自已为源输出就使用--sport)
- -A OUTPUT -p tcp -m tcp --sport -j ACCEPT
- -A OUTPUT -p tcp -m tcp --sport -j ACCEPT
- -A OUTPUT -p tcp -m tcp --sport -j ACCEPT
- -A OUTPUT -p tcp -m tcp --sport -j ACCEPT
- COMMIT
- # Completed on Fri Mar ::
以上都是16年有段时间安装过程所做的记录,最近整理笔记整理出来,先放这里吧!如有错误请各位指正!谢谢
Linux 上关于iptables的更多相关文章
- 在Linux上使用iptables命令开启对外访问的网络端口
如果linux下没有开启对某端口访问权限,你可以通过下面的命令可以开启允许对外访问的网络端口,示例如下: [root@asg76 sysconfig]# iptables -I INPUT -p tc ...
- (转载)Linux上iptables防火墙的基本应用教程
(转载)http://www.vpser.net/security/linux-iptables.html iptables是Linux上常用的防火墙软件,下面vps侦探给大家说一下iptables的 ...
- Linux上iptables防火墙的基本应用教程
iptables是Linux上常用的防火墙软件,下面vps侦探给大家说一下iptables的安装.清除iptables规则.iptables只开放指定端口.iptables屏蔽指定ip.ip段及解封. ...
- 【Oracle 集群】11G RAC 知识图文详细教程之RAC在LINUX上使用NFS安装前准备(六)
RAC在LINUX上使用NFS安装前准备(六) 概述:写下本文档的初衷和动力,来源于上篇的<oracle基本操作手册>.oracle基本操作手册是作者研一假期对oracle基础知识学习的汇 ...
- Linux防火墙:iptables禁IP与解封IP常用命令
在Linux服务器被攻击的时候,有的时候会有几个主力IP.如果能拒绝掉这几个IP的攻击的话,会大大减轻服务器的压力,说不定服务器就能恢复正常了. 在Linux下封停IP,有封杀网段和封杀单个IP两种形 ...
- linux上nagios安装完整版
监控server端的安装部署一.apache的安装下载httpd-2.2.15.tar.gz gunzip httpd-2.2.15.tar.gztar xvf httpd-2.2.15.tarcd ...
- linux中利用iptables+geoip过滤指定IP
1. 前提条件 iptables >= 1.4.5 kernel-devel >= 3.7 2. 安装依赖包 代码如下 复制代码 # yum install gcc gcc-c++ m ...
- linux上tomcat安装
转载:http://my.oschina.net/zmf/blog/309484 tomcat安装 下载后解压:tar -zxvf apache-tomcat-7.0.28 移动到/usr/local ...
- 服务器上的iptables
服务器上的iptables 防火墙设置脚本规则 完整脚本如下: 复制代码代码示例: #!/bin/bash# by www.jbxue.comiptab="/sbin/iptables&qu ...
随机推荐
- ASP.NET CORE RAZOR :个性化显示
https://docs.microsoft.com/zh-cn/aspnet/core/tutorials/razor-pages/da1 我们的电影应用有个不错的开始,但是展示效果还不够理想. 我 ...
- poj 3468 A Simple Problem with Integers 【线段树-成段更新】
题目:id=3468" target="_blank">poj 3468 A Simple Problem with Integers 题意:给出n个数.两种操作 ...
- 如何去掉MapReduce输出的默认分隔符
我们在用MapReduce做数据处理的时候,经常会遇到将只需要输出键或者值的情况,如context.write(new Text(record), new Text("")),这样 ...
- surface4 笔盖失灵的解决方案
http://tieba.baidu.com/p/3670357234 先找到设备管理器,找到蓝牙,删除里面所有的设备.然后重启. 之后再次找到蓝牙,匹配pen.就可以用了. 解决的前提是:我确定笔帽 ...
- linux系统下面ftp的一些命令
service vsftpd restart重启vsftpd服务service vsftpd stop停止vsftpd服务service vsftpd start启动vsftpd服务 chkconfi ...
- 怎样在fastboot 里面加入新的命令
fastboot 是android 默认的一种debug 方法.它的优点是在进入linux kernel 之前就可以操作. 默认fastboot 支持的命令: usage: fastboot [ &l ...
- tensorflow-gpu 1.13 提示找不到 libcublas.so.10.0 的问题
tensorflow-gpu 使用 1.13.1,cuda-10-0已安装好,但启动时依然报错 ImportError: libcublas.so.10.0: cannot open shared o ...
- Trie|如何用字典树实现搜索引擎的关键词提示功能
Trie字典树 Trie字典树又称前缀树,顾名思义,是查询前缀匹配的一种树形数据结构 可以分为插入(创建) 和 查询两部分.参考地址极客时间 下图为插入字符串的过程: 创建完成后,每个字符串最后一个字 ...
- centos7 改变终端背景色
首先打开终端 2:选择 edit->preferences->profile 3: "model1"是我自己改的名字,最开始是"unname".双击 ...
- SpringSide4 maven
假设已经安装完 maven eclipse也装了maven插件 现在要运行springside4 demo 1)下载 SpringSide4 http://www.springside.org.cn ...