CentOS 7关闭firewalld启用iptables 开放端口
在CentOS7中,有很多CentOS 6中的常用服务发生了变化。
其中iptables是其中比较大的一个。防火墙iptables被firewalld取代。
本文将介绍,如果采用systemctl关闭firewalld,开启iptables。
1.关闭firewalld
[root@hwcentos70-01 system]# systemctl stop firewalld
[root@hwcentos70-01 system]# systemctl disable firewalld
[root@hwcentos70-01 system]# systemctl status firewalld
firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled) Active: inactive (dead) Feb 26 13:48:00 hwcentos70-01 systemd[1]: Stopped firewalld - dynamic firewall daemon. Feb 26 13:48:14 hwcentos70-01 systemd[1]: Starting firewalld - dynamic firewall daemon... Feb 26 13:48:15 hwcentos70-01 systemd[1]: Started firewalld - dynamic firewall daemon. Feb 26 13:49:23 hwcentos70-01 systemd[1]: Started firewalld - dynamic firewall daemon. Feb 26 13:53:18 hwcentos70-01 systemd[1]: Stopping firewalld - dynamic firewall daemon... Feb 26 13:53:18 hwcentos70-01 systemd[1]: Stopped firewalld - dynamic firewall daemon.
2.开启iptables
首先安装iptables:
[root@hwcentos70-01 system]#yum install -y iptables-services
[root@hwcentos70-01 system]# systemctl enable iptables
ln -s '/usr/lib/systemd/system/iptables.service' '/etc/systemd/system/basic.target.wants/iptables.service' [root@hwcentos70-01 system]# systemctl start iptables
[root@hwcentos70-01 system]# systemctl status iptables
iptables.service - IPv4 firewall with iptables Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled) Active: active (exited) since Fri 2016-02-26 13:54:45 UTC; 6s ago Process: 55539 ExecStart=/usr/libexec/iptables/iptables.init start (code=exited, status=0/SUCCESS) Main PID: 55539 (code=exited, status=0/SUCCESS) Feb 26 13:54:45 hwcentos70-01 iptables.init[55539]: iptables: Applying firewall rules: [ OK ] Feb 26 13:54:45 hwcentos70-01 systemd[1]: Started IPv4 firewall with iptables.
此时iptables的命令都可以使用了:
[root@hwcentos70-01 system]# 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@hwcentos70-01 system]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
3.开放5000端口
输入“vi /etc/sysconfig/iptables”,打开iptables的配置文件,输入之前按一下"i",然后添加一行"-A INPUT -m state --state NEW -m tcp -p tcp --dport 5000 -j ACCEPT",添加以后按一下ESC,输入":x",回车,就保存退出了

重启iptables,输入"service iptables restart",重启成功以后,,输入"service iptables status",回车,就会显示正在生效的规则
启动监听5000的应用程序
4.测试
cmd(命令提示符)窗口,使用telnet命令进行测试,命令"telnet+空格+服务器IP+空格+5000",可以连接就会直接跳转到一个空白的窗口,连不上就会卡住一段时间,然后提示错误

查看网页

CentOS 7关闭firewalld启用iptables 开放端口的更多相关文章
- CentOS 7关闭firewalld启用iptables
在CentOS7中,有很多CentOS 6中的常用服务发生了变化. 其中iptables是其中比较大的一个.防火墙iptables被firewalld取代. 本文将介绍,如果采用systemctl关闭 ...
- centos 7 关闭firewalld开启iptables
1: 关闭系统高级防火墙firewalld systemctl stop firewalld.service #停止firewall systemctl disable firewalld.servi ...
- [转载]CENTOS 6.0 iptables 开放端口80 3306 22端口
原文地址:6.0 iptables 开放端口80 3306 22端口">CENTOS 6.0 iptables 开放端口80 3306 22端口作者:云淡风轻 #/sbin/iptab ...
- 玩转Linux之- CentOS 7.0,启用iptables防火墙
原文 玩转Linux之- CentOS 7.0,启用iptables防火墙 CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall:sy ...
- Centos7防火墙关闭和启用iptables操作
https://yq.aliyun.com/ziliao/33590前序 还是docker惹得最近做的系统都是上的centos7的系统带来的一系列的新环境的适应 补记下:在使用oracle vmbox ...
- Centos7 防火墙关闭和启用iptables防火墙
操作系统环境:CentOS Linux release 7.0.1406(Core) 64位CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤. 1.关闭f ...
- linux命令启动关闭firewalld防火墙,添加端口
firewalld管理防火墙常用命令 1.查看防火墙的状态 [root@localhost HMK]# firewall-cmd --state 查看防火墙的运行状态 not running [r ...
- Linux 防火墙iptables开放端口
Iptabels是与Linux内核集成的包过滤防火墙系统,几乎所有的linux发行版本都会包含Iptables的功能.如果 Linux 系统连接到因特网或 LAN.服务器或连接 LAN 和因特网的代理 ...
- CentOS 8 关闭 Firewalld 及 SELinux
检查 SELinux 是否开启 执行 sestatus 指令可以检视目前 SELinux 的状态, 其中一项是是否有开启, 执行以下指令: # sestatus | grep status 如果看到 ...
随机推荐
- 使用scrapy爬取jian shu文章
settings.py中一些东西的含义可以看一下这里 python的scrapy框架的使用 和xpath的使用 && scrapy中request和response的函数参数 & ...
- 牛客小白月赛30 J.小游戏 (DP)
题意:给你一组数,每次可以选择拿走第\(i\)个数,得到\(a[i]\)的分数,然后对于分数值为\(a[i]-1\)和\(a[i]+1\)的值就会变得不可取,问能得到的最大分数是多少. 题解:\(a[ ...
- Codeforces Round #680 (Div. 2, based on Moscow Team Olympiad) C. Division (数学)
题意:有两个数\(p\)和\(q\),找到一个最大的数\(x\),使得\(p\ mod\ x=0\)并且\(x\ mod\ q\ne 0\). 题解:首先,如果\(p\ mod\ q\ne0\),那么 ...
- Long Long Message POJ - 2774 后缀数组
The little cat is majoring in physics in the capital of Byterland. A piece of sad news comes to him ...
- c#中几种常见的数据结构
数组(Array): 1.数组存储在连续的内存上 2.数组的元素类型必须相同 3.数组可以直接通过下标访问 4.查找与修改元素的速度非常快 5.必须在声明时指定长度 动态数组(ArrayLis ...
- WSL2 VS Code远程开发.Net Core
修改 我们打开一个页面,随便修改一下,保存,结果会出现错误:Unable to write file (NoPermissions (FileSystemError): Error: EACCES: ...
- jenkins:实现Jenkinsfile与Json的转换
实现Jenkinsfile与Json的转换 目录 实现Jenkinsfile与Json的转换 方法1:使用现有的jenkins插件 参考 方法2:解析原生的jenkinsfile文件 参考 最近在做个 ...
- ElasticSearch 交互使用
Curl 命令 # 建立索引 [root@dbtest01 ~]# curl -XPUT 'http://10.0.0.121:9200/test' # 插入数据 [root@dbtest01 ~]# ...
- Leetcode(8)-字符串转整数
实现 atoi,将字符串转为整数. 在找到第一个非空字符之前,需要移除掉字符串中的空格字符.如果第一个非空字符是正号或负号,选取该符号,并将其与后面尽可能多的连续的数字组合起来,这部分字符即为整数的值 ...
- C# Dictionaries
Dictionaries 字典 在C# 里是用接口 IDictionary来实现的,最常用的字典就是Dicrtionary<tkey,tvalue>,键值对的形式,和index,item ...