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

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

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

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


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

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

分享给朋友:

相关文章

linux 云服务器挂载云盘

https://cloud.tencent.com/developer/article/1852198?from=15425查看硬盘fdisk -lWARNING: fdisk&n...

贴吧遇到的坑

发帖频率 在同一个吧,频率不会有太大限制,我看到一个账号连续发了30个帖子。发帖频率,不同吧,同一个号间隔最好大于5分钟。...

视频号三种直播方式、推流直播、绿幕直播解决方案

视频号三种直播方式、推流直播、绿幕直播解决方案

用视频号做公开课直播或内部课直播很方便,但是目前自带功能无法实现回放,这样很多错过的小伙伴就看不到了~视频号用手机直播无法换好看高大上的背景,无法展示课程幻灯片,无法方便展示二维码课件等内容~如何不买...

linux下mysql忘记密码怎么办

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

JS使用H5实现图片预览

JS使用H5实现图片预览

<!DOCTYPE html><html><head><meta charset="UTF-8"><title>文件上传...

安装飞桨https://www.paddlepaddle.org.cn/

是在python3.8下成功的yum install python38python3.8 -m pip install paddlepaddle==2.3.2 -i https://pypi.tuna...