当前位置:首页 > 技术记录 > 正文内容

CentOS 7关闭firewalld启用iptables 开放端口

ogfogf4年前 (2021-11-18)技术记录1723

在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的命令都可以使用了:


扫描二维码推送至手机访问。

版权声明:本文由技术建站文档发布,如需转载请注明出处。

分享给朋友:

相关文章

A股各细分行业龙头

锂电池各类细分1.电池:宁德时代、比亚迪、亿纬锂能、国轩高科、鹏辉能源、川能动力、欣旺达。2.正极材料:a.三元正极:容百科技、当升科技、杉杉能源(杉杉股份 )、格林美、中伟股份、厦钨新能(厦门钨业...

json_encode("中文", JSON_UNESCAPED_UNICODE);

json_encode("中文", JSON_UNESCAPED_UNICODE);...

linux下mysql忘记密码怎么办

前言今天在服务器安装mysql之后,登录发现密码错误,但是我没有设置密码呀,最后百度之后得知,mysql在5.7版本之后会自动创建一个初始密码。报错如下:[root@mytestlnx02 ...

linux查看端口常用命令

netstat命令参数:  -t : 指明显示TCP端口  -u : 指明显示UDP端口  -l : 仅显示监听套接字(所谓套接字就是使应用程序能够读写与收发通讯协议(protocol)与资料的程序)...

mariadb 在低配 VPS 上崩溃问题处理方案

本文章向大家介绍mariadb 在低配 VPS 上崩溃问题处理方案,主要包括mariadb 在低配 VPS 上崩溃问题处理方案使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要...

采集品牌chinaapp数据

1至3个 $pregstr = "/<div class\=\"Various\" id\=\"voteList_shida\">([\s...