最近由于项目需要,需要打开防火墙功能.

公司有

arm linux 3.0
x86 linux 3.2
x86 linux 2.4

的三个嵌入式.都需要打开防火墙功能.

执行“whereis iptables”命令,如果结果不为空,则说明防火墙软件已安装

# whereis iptables
iptables: /sbin/iptables /usr/share/iptables /usr/share/man/man8/iptables.8.gz
root@wheezy-armel:~ 9:26:57

输入iptables -L 命令查看配置

# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination Chain FORWARD (policy ACCEPT)
target prot opt source destination Chain OUTPUT (policy ACCEPT)
target prot opt source destination
root@wheezy-armel:~ 9:27:32
#

此处为空表示 没有配置防火墙.

此处可参考:

#知识:
# http://blog.chinaunix.net/uid-9950859-id-98279.html
# http://blog.slogra.com/post-232.html
# http://www.cnblogs.com/bangerlee/archive/2013/02/27/2935422.html
# http://blog.chinaunix.net/uid-26495963-id-3279216.html

保存本文件,然后把本规则加载,使之生效,注意,iptables不需要重启,加载一次规则就成了
sudo iptables-restore < /etc/iptables.test.rules
然后再查看最新的配置,应该所有的设置都生效了.
sudo iptables -L

第四步:保存生效的配置,让系统重启的时候自动加载有效配置
iptables提供了保存当前运行的规则功能
iptables-save > /etc/iptables.up.rules

结果执行时报错.

# iptables -A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied:" --log-level 7
iptables: No chain/target/match by that name.

网上搜索是缺少内核模块

root@wheezy-armel:~  9:30:27
# lsmod |grep iptables
root@wheezy-armel:~ 9:31:04
#

是没有输出的.

root@wheezy-armel:~  9:31:04
# iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables: No chain/target/match by that name.

后面发现是 有了-m state    RELATED,ESTABLISHED  之类的就报错.

就是对tcp 的连接状态:

  NEW
        ESTABLISHED
        RELATED
        INVALID
貌似都不能处理 .
 iptables -t filter -A INPUT -s 172.16.0.0/16 -p udp --dport 53 -j DROP
当然你如果想拒绝的更彻底:
iptables -t filter -R INPUT 1 -s 172.16.0.0/16 -p udp --dport 53 -j REJECT

如果用DROP可以成功,用REJECT会报错.

最后改成了:

常用的ACTION:
DROP:悄悄丢弃
一般我们多用DROP来隐藏我们的身份,以及隐藏我们的链表
REJECT:明示拒绝
ACCEPT:接受
custom_chain:转向一个自定义的链
DNAT
SNAT
MASQUERADE:源地址伪装
REDIRECT:重定向:主要用于实现端口重定向
MARK:打防火墙标记的
RETURN:返回
在自定义链执行完毕后使用返回,来返回原规则链。

简单说就是只能用低级功能,不能用高级功能.

最后修改后的命令文件是

# Generated by iptables-save v1.4.14 on Tue May  6 14:54:02 2014

#知识:
# http://blog.chinaunix.net/uid-9950859-id-98279.html
# http://blog.slogra.com/post-232.html
# http://www.cnblogs.com/bangerlee/archive/2013/02/27/2935422.html
# http://blog.chinaunix.net/uid-26495963-id-3279216.html #1.PREROUTING (路由前)
#2.INPUT (数据包流入口)
##3.FORWARD (转发管卡)
#4.OUTPUT(数据包出口)
#5.POSTROUTING(路由后) *filter
:INPUT ACCEPT [1:40]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0] #允许本地回环接口(即运行本机访问本机)
#-A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
#允许本地回环接口(即运行本机访问本机)
-A INPUT -i lo -j ACCEPT #允许所有本机向外的访问
-A OUTPUT -j ACCEPT # arm linux 3.0不可用...
#-A INPUT -d 127.0.0.0/8 ! -i lo -j REJECT --reject-with icmp-port-unreachable
#-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT # Allows xxxx port 允许访问 xxxx的端口
#xxx或xxx可能有多个端口,请在这儿添加.
#这儿是tcp
-A INPUT -p tcp -m tcp --dport 1234 -j ACCEPT #这儿是udp
#-A INPUT -p udp -m udp --dport 1234 -j ACCEPT # Allows Mysql port 允许访问 mysql 的端口
#-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
-A INPUT -p tcp --dport 3306 -j ACCEPT # Allows SSH port
#***如果不允许这个,你就先去一边哭会吧.
#***如果不允许这个,你就先去一边哭会吧.
-A INPUT -p tcp --dport 22 -j ACCEPT
#-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT # 允许 ping 这个和禁用ping ,2选1.
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
#禁用ping
#-A INPUT -p icmp -m icmp --icmp-type 8 -j DROP #记录日志功能,arm linux 3.0不可用...
#-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied:" --log-level 7
# arm linux 3.0不可用...
#-A INPUT -j REJECT --reject-with icmp-port-unreachable
# arm linux 3.0不可用...
#-A FORWARD -j REJECT --reject-with icmp-port-unreachable #拒绝 未定义规则.(注意:如果22端口未加入允许规则,SSH链接会直接断开。) REJECT
-A INPUT -j DROP
-A FORWARD -j DROP COMMIT
# Completed on Tue May 6 14:54:02 2014
# Generated by iptables-save v1.4.14 on Tue May 6 14:54:09 2014

arm,iptables: No chain/target/match by that name.的更多相关文章

  1. centos6.8 docker0: iptables: No chain/target/match by that name

    现象:之前docker gitlab运行的一直好好的,突然有一天访问不了,但容器却还运行着.于是我把gitlab容器重启,发现启动不了了,报错:docker0: iptables: No chain/ ...

  2. [转]启动container的时候出现iptables: No chain/target/match by that name

    本文转自:https://blog.csdn.net/u013948858/article/details/83115388 问题: Error response from daemon: drive ...

  3. 启动docker容器 防火墙问题报错 ! -i docker0' failed: iptables: No chain/target/match by that name.

    COMMAND_FAILED: '/sbin/iptables -t nat -A DOCKER -p tcp -d 0/0 --dport 8111 -j DNAT --to-destination ...

  4. iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 8001 -j DNAT --to-destination 172.17.0.5:8080 ! -i docker0: iptables: No chain/target/match by that name.

    在docker容器上部署项目后,启动docker容器,出现 iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dpor ...

  5. 【Docker】iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 8480 -j DNAT --to-destination 172.17.0.2:80 ! -i docker0: iptables: No chain/target/match by that name

    启动容器的时候,出现如下错误: Error response / --dport -j DNAT --to-destination ! -i docker0: iptables: No chain/t ...

  6. docker运行报错docker0: iptables: No chain/target/match by that name.

    转自:https://blog.csdn.net/wohaqiyi/article/details/84450562 docker运行报错docker0: iptables: No chain/tar ...

  7. iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 3306 -j DNAT --to-destination 172.17.0.2:3306 ! -i docker0: iptables: No chain/target/match by that name

    今天使用docker运行mysql时报错, 执行命令: docker run --restart=always --name mysql5.7 -p 3306:3306 -v /data/mysql/ ...

  8. centos7 解决docker0: iptables: No chain/target/match by that name

    解决步骤: 1.查看iptables状态,查看是否正常docker需要依赖该服务 service iptables status 注:我都服务就发现iptables服务的有问题 2.查看iptable ...

  9. docker 端口映射iptables: No chain/target/match by that name错误解决方法

    pkill docker iptables -t nat -F ifconfig docker0 down brctl delbr docker0 service docker restart

随机推荐

  1. WebService -- Java 实现之 CXF ( 使用Spring添加拦截器)

    最重要的就是在ApplicationContext.xml下面添加配置 <!-- service provider --> <jaxws:endpoint implementor=& ...

  2. [转]加速Android Studio/Gradle构建

    加速Android Studio/Gradle构建 android android studio gradle   已经使用Android Studio进行开发超过一年,随着项目的增大,依赖库的增多, ...

  3. nginx负载均衡集群

    nginx负载均衡集群  0.前言:nginx 负载均衡,属于网络7层模型中的应用层,说白了就是一个代理,要用 upstrem 模块实现,代理则用proxy模块 1.可以针对域名做转发,lvs只能针对 ...

  4. SQL(横表和纵表)行列转换,PIVOT与UNPIVOT的区别和使用方法举例,合并列的例子

    使用过SQL Server 2000的人都知道,要想实现行列转换,必须综合利用聚合函数和动态SQL,具体实现起来需要一定的技巧,而在SQL Server 2005中,使用新引进的关键字PIVOT/UN ...

  5. debian命令行删除postgresql数据库

    创建数据库 $ createdb odoo-test 删除数据库 $ dropdb odoo-test

  6. 关于Python对齐问题

    最近在学习父与子的编程之旅,书上有一个关于猜数的游戏代码,自己敲了以后老是不对,仔细检查后发现是对齐问题. 废话不说了,直接上图: 上面是正确的,下面这个是有问题的,大家可以看下Python代码如果没 ...

  7. 手把手教你玩转nginx负载均衡(一)----使用vitualBox创建虚拟机

    引言 作为一个web程序员,有时候需要想尽办法来利用有限的资源来产生最大程度的负载,除了提高硬件配置,增加带宽之外,CDN加速,DNS加速,缓存,还可以利用反向代理.但是要说反向代理,就不的不说ngi ...

  8. CSS 布局

    近日开发中,总感觉页面布局方面力不从心.以前也曾学过这方面的内容,但是不够系统,因此我打算整理一下. 在web 页面中一般有 table 和 css+div 两种布局方式. 其中css+div 又分为 ...

  9. 获取系统中所有进程&线程信息

    读书笔记--[计算机病毒解密与对抗] 目录: 遍历进程&线程程序 终止进程 获取进程信息 获取进程内模块信息 获取进程命令行参数 代码运行环境:Win7 x64 VS2012 Update3 ...

  10. js获取URL中的参数

    js获取URL中的一些参数的意思 location对象 含有当前URL的信息. 属性 href 整个URL字符串. protocol 含有URL第一部分的字符串,如http: host 包含有URL中 ...