Ubuntu使用iptables配置防火墙提示:unrecognized service(Ubuntu配置iptables防火墙)
Ubuntu默认安装是没有开启任何防火墙的。
当使用service iptables status时发现提示iptables:unrecoginzed service。意思是无法识别的服务。
以下方法来自http://blog.csdn.net/lywzgzl/article/details/39938689,但是测试发现,此方法已经无法在Ubuntu中使用
#在ubuntu中由于不存在/etc/init.d/iptales文件,所以无法使用service等命令来启动iptables,需要用modprobe命令。
#启动iptables
modprobe ip_tables
#关闭iptables(关闭命令要比启动复杂)
iptables -F
iptables -X
iptables -Z
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
modprobe -r ip_tables
#依次执行以上命令即可关闭iptables,否则在执行modproble -r ip_tables时将会提示
#FATAL: Module ip_tables is in use.
通过以上方法,最终无法解决,通过研究发现,以上的命令已经是旧版,在新版中iptables本身不是一个服务。
而如果要继续使用iptables配置,可以通过来自http://www.cnblogs.com/general0878/p/5757377.html的方法去实现:
1、查看系统是否安装防火墙
sudo whereis iptables
出现如上提示表示已经安装iptables,如果没有安装,可以通过以下命令安装
sudo apt-get install iptables
2、查看防火墙的配置信息
sudo iptables -L
3、新建规则文件
mkdir /etc/iptables #先新建目录,本身无此目录
vi /etc/iptables/rules.v4
两条合起来的命令可以简化成以下写法
mkdir /etc/iptables & vi /etc/iptables/rules.v4
添加以下内容(备注:80是指web服务器端口,3306是指MySQL数据库链接端口,22是指SSH远程管理端口)
*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:syn-flood - [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
-A INPUT -p icmp -m limit --limit 100/sec --limit-burst 100 -j ACCEPT
-A INPUT -p icmp -m limit --limit 1/s --limit-burst 10 -j ACCEPT
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j syn-flood
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A syn-flood -p tcp -m limit --limit 3/sec --limit-burst 6 -j RETURN
-A syn-flood -j REJECT --reject-with icmp-port-unreachable
COMMIT
4、使防火墙生效
iptables-restore < /etc/iptables/rules.v4
5、创建文件,添加以下内容,使防火墙开机启动
vi /etc/network/if-pre-up.d/iptables
#!/bin/bash
iptables-restore < /etc/iptables/rules.v4
6、添加执行权限
chmod +x /etc/network/if-pre-up.d/iptables
7、查看规则是否生效
iptables -L -n
通过以上方法可以在Ubuntu上正常通过,并且可以清晰的知道其依赖关系。
再或者如果要折腾iptables的用法,可以参考以下收集的文章进行配置:
https://serverfault.com/questions/129086/how-to-start-stop-iptables-on-ubuntu
https://help.ubuntu.com/community/IptablesHowTo
经过研究发现,在Ubuntu/Debian系统上有一个防火墙的简化版,叫做UFW,原理还是iptables,但是由于iptables需要操作的表和关系很多,所以使用UFW来简化这些操作。
Ubuntu使用iptables配置防火墙提示:unrecognized service(Ubuntu配置iptables防火墙)的更多相关文章
- SAP SOAMANAGER 配置WEBSERVICE 提示:Service cannot be reached解决方法
TM中有些服务没有被激活,以UI界面个性化设置化设置为例: 如果服务没有被激活,打开界面就会显示: 这时候右键点击属性,获取服务ID: 通过事务代码SICF,输入服务ID:wd_analyze_con ...
- Ubuntu 16.04下操作iptables的技巧(解决Failed to start iptables.service: Unit iptables.service not found.或者/etc/init.d/iptables: 没有那个文件或目录)
/etc/init.d/iptables网上的解法应该都是基于CentOS 6去实践,而在CentOS 7中又被firewalld给取代,所以操作上的写法基本会改变,但是底层iptables则不会改变 ...
- 防火墙centos7执行 service iptables status报错问题完美解决
在centos7 执行防火墙命令时 service iptables status 报错如下: 解决方案 : 1.systemctl start firewalld.service(开启防火墙) 2. ...
- iptables实用知识 ,一文学会配置linux防火墙
目录 1.防火墙的概念 2. linux防火墙 3.linux数据包处理流程 3.1 linux 防火墙将以上流程,固定区分为5个流程节点 3.2 数据流程 4 linux防火墙的实现机制 4.1 i ...
- ubuntu Linux 测试PHP却提示下载文件的解决办法
ubuntu Linux 测试PHP却提示下载文件的解决办法 一般这种情况都是在刚刚开始配置环境时出现的, 输入 sudo a2enmod php5 看提示如果出现“$ This module ...
- iptables log日志记录功能扩展应用:iptables自动配置临时访问策略,任意公网登录服务器
一.修改日志记录: 1. 修改配置文件: vi /etc/rsyslog.conf 添加以下内容 #iptables log kern.=notice /var/log/iptables.log 2. ...
- Service系统服务(五):PXE基础装机环境、配置并验证DHCP服务、配置PXE引导、验证PXE网络装机、PXE+kickstart自动装机
一.PXE基础装机环境 目标: 本例要求为后续的PXE服务器构建提供RHEL7软件仓库,完成下列任务: 1> 在CentOS真机部署Web目录/var/www/html/rh7dvd 2&g ...
- CentOS7 执行 service iptables save 报错 The service command supports only basic LSB actions xxxxxx
现象描述 在 CentOS 7.6.1810 下执行 service iptables save 命令,出现如下错误: [root@test ~]# service iptables save The ...
- smb:unrecognized service
[root@sycflash ~]#service smb status smb:unrecognized service 提示:smb:unrecognized service.这时你会按照常规的方 ...
随机推荐
- Ruby设计模式-观察者模式学习笔记
observer.rb #!/bin/env ruby # encoding: utf-8 require 'observer' class CriminalMovement include Obse ...
- 【动态规划】bzoj2298: [HAOI2011]problem a
建模超级妙…… Description 一次考试共有n个人参加,第i个人说:“有ai个人分数比我高,bi个人分数比我低.”问最少有几个人没有说真话(可能有相同的分数) Input 第一行一个整数n,接 ...
- PyCharm学习笔记(二) 调试配置
选择PyCharm编译器 注意工程默认使用的解释器可能是Pycharm自带的,而不是单独安装的.
- 经典DP问题--poj1088滑雪
Description Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激.可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你.Michael想知道 ...
- Appium自动化-基于java的环境搭建
引言 自动化测试框架搭建主要分为以下几个方面的下载安装及环境配置: 1.jdk 2. adt 3. appium 4. testng插件 工具链接: https://pan.baidu.com/s/1 ...
- 【LeetCode】Available Captures for Rook(车的可用捕获量)
这道题是LeetCode里的第999道题. 题目叙述: 在一个 8 x 8 的棋盘上,有一个白色车(rook).也可能有空方块,白色的象(bishop)和黑色的卒(pawn).它们分别以字符 &quo ...
- 【Python】SyntaxError: Non-ASCII character '\xe8' in file
遇到的第一个问题: SyntaxError: Non-ASCII character '\xe8' in file D:/PyCharmProject/TempConvert.py on line 2 ...
- hdu2081
#include <stdio.h> #include <malloc.h> int main(){ ]; char *p; int t; p=(); scanf(" ...
- 【bzoj3231】[Sdoi2008]递归数列 矩阵乘法+快速幂
题目描述 一个由自然数组成的数列按下式定义: 对于i <= k:ai = bi 对于i > k: ai = c1ai-1 + c2ai-2 + ... + ckai-k 其中bj和 cj ...
- BZOJ 2820 YY的GCD ——莫比乌斯反演
我们可以枚举每一个质数,那么答案就是 $\sum_{p}\sum_{d<=n}\mu(d)*\lfloor n / pd \rfloor *\lfloor m / pd \rfloor$ 直接做 ...