Centos7 禁止firewalld并使用iptables 作默认防火墙以及忘记root密码的处理方法

时间:2022-06-25 05:57:52

一、停止并禁用firewalld

[root@test ~]# systemctl stop firewalld
[root@test ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

二、查看iptables 列表,并安装service 软件

Centos7 禁止firewalld并使用iptables 作默认防火墙以及忘记root密码的处理方法
[root@test ~]# yum list all iptables*
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.neusoft.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.sina.cn
已安装的软件包
iptables.x86_64 1.4.21-16.el7 @base
可安装的软件包
iptables.i686 1.4.21-16.el7 base
iptables-devel.i686 1.4.21-16.el7 base
iptables-devel.x86_64 1.4.21-16.el7 base
iptables-services.x86_64 1.4.21-16.el7 base
iptables-utils.x86_64 1.4.21-16.el7 base
Centos7 禁止firewalld并使用iptables 作默认防火墙以及忘记root密码的处理方法

安装service

[root@test ~]# yum install iptables-services -y

三、启动iptables服务,并检查状态

Centos7 禁止firewalld并使用iptables 作默认防火墙以及忘记root密码的处理方法
[root@test ~]# systemctl start iptables
[root@test ~]# systemctl status iptables
● iptables.service - IPv4 firewall with iptables
Loaded: loaded (/usr/lib/systemd/system/iptables.service; disabled; vendor preset: disabled)
Active: active (exited) since 五 2016-08-05 07:54:57 CST; 9s ago
Process: 8164 ExecStart=/usr/libexec/iptables/iptables.init start (code=exited, status=0/SUCCESS)
Main PID: 8164 (code=exited, status=0/SUCCESS) 8月 05 07:54:56 test systemd[1]: Starting IPv4 firewall with iptables...
8月 05 07:54:57 test iptables.init[8164]: iptables: Applying firewall rules: [ OK ]
8月 05 07:54:57 test systemd[1]: Started IPv4 firewall with iptables.
Centos7 禁止firewalld并使用iptables 作默认防火墙以及忘记root密码的处理方法

四、加入开机自启动

[root@test ~]# systemctl enable iptables
Created symlink from /etc/systemd/system/basic.target.wants/iptables.service to /usr/lib/systemd/system/iptables.service.

另:systemctl命令相关

如何激活服务并在启动时启用或禁用服务(即系统启动时自动启动服务)

# systemctl enable httpd.service

# systemctl disable httpd.service

如何屏蔽(让它不能启动)或显示服务(如 httpd.service)

# systemctl mask httpd.service

ln -s '/dev/null' '/etc/systemd/system/httpd.service'

# systemctl unmask httpd.service

rm '/etc/systemd/system/httpd.service

列出所有服务(包括启用的和禁用的):

# systemctl list-unit-files --type=service
UNIT FILE STATE
arp-ethers.service disabled
auditd.service enabled
autovt@.service disabled
blk-availability.service disabled
brandbot.service static
console-getty.service disabled
console-shell.service disabled
container-getty@.service static
...

分析启动时各个进程花费的时间:

# systemd-analyze blame
8.565s mariadb.service
7.991s webmin.service
6.095s postfix.service
4.311s httpd.service
3.926s firewalld.service
3.780s kdump.service
3.238s tuned.service
1.712s network.service
1.394s lvm2-monitor.service
1.126s systemd-logind.service
....

更多参考:https://linux.cn/article-5926-1.html

------------------------------------------------------------------------------------------

忘记root密码时:

1 - 在启动grub菜单,选择编辑选项启动
2 - 按键盘e键,来进入编辑界面
3 - 找到Linux 16的那一行,将ro改为rw init=/sysroot/bin/sh
4 - 现在按下 Control+x ,使用单用户模式启动

Centos7 禁止firewalld并使用iptables 作默认防火墙以及忘记root密码的处理方法的更多相关文章

  1. Centos7 禁止firewalld并使用iptables 作默认防火墙

    一.停止并禁用firewalld [root@test ~]# systemctl stop firewalld [root@test ~]# systemctl disable firewalld ...

  2. CentOS7忘记root密码的解决方法

    开机启动centos 7.0,看到如下画面,选择下图选单,按"e"键 在下图linux16行中,将ro这两个字母修改为rw init=/sysroot/bin/sh 修改结果如下图 ...

  3. centos7忘记root密码的重置方法-超简单

    忘记root密码,重置root密码8步. 1.在开机界面按e进入grub编辑模式 2.找到 ro修改为rw /sysroot/bin/sh 3.Ctrl + x 启动 4.chroot /sysroo ...

  4. CentOS7忘记root密码的修改方法

    参考文献: [1]CentOS 6 & 7 忘记root密码的修改方法_Linux教程_Linux公社-Linux系统门户网站

  5. CentOS7下mysql忘记root密码的处理方法

    1.  vi /etc/my.cnf,在[mysqld]中添加 skip-grant-tables 例如: [mysqld] skip-grant-tables datadir=/var/lib/my ...

  6. CentOS7|RHEL忘记root密码

    某一服务器长时间不使用,或者由于频繁修改root密码,导致忘记root密码无法登陆系统问题,通过进入单用户修改root密码,CentOS7|RHEL7与6系列有一些区别,不在适用于7. 1.在启动gr ...

  7. 其它综合-CentOS7 忘记root密码

    CentOS7 忘记root密码 长时间不用的 CentOS 机器再次开机的时候忽然忘记了密码,总不能就重装一台吧,还有好多服务在机器上,于是决定重置root的密码. 如果是已经开启的机器,需要进行关 ...

  8. 其它综合-CentOS7 解决忘记root密码

    CentOS7 解决忘记root密码 1.重启 长时间不用的 CentOS 机器再次开机的时候忽然忘记了密码,总不能就重装一台吧,还有好多服务在机器上,于是决定重置 root 的密码. 如果是已经开启 ...

  9. 0、CentOS7系统root密码丢失找回方法

    第一步 1.重新启动或开启CentOS7.6系统,在选择进入系统的Grub菜单界面如下图1-1,根据提示按"e"小写字母进入编辑界面,如下图1-2所示: 图1-1 CentOS7. ...

随机推荐

  1. 在DirectX9中使用DXUT定制按钮来控制模型旋转的问题

    使用DXUT中的按钮控件类实现 控制模型旋转的过程如下: 1.创建一个CDXUTDialog对话框,并绑定至CDXUTDialogResourceManager对话框资源管理器. 2.绑定回调函数GU ...

  2. 在Application中集成Microsoft Translator服务之开发前准备

    第一步:准备一个微软账号 要使用Microsoft Translator API需要在Microsoft Azure Marketplace(https://datamarket.azure.com/ ...

  3. LeetCode之104. Maximum Depth of Binary Tree

    -------------------------------- 递归遍历即可 AC代码: /** * Definition for a binary tree node. * public clas ...

  4. google打不开啦,咋办?

    前言:以前开发的时候一直使用google浏览器,好像是两年前的某一天突然间发现google搜索不能访问了,我喜欢将自己觉得有趣的网页做成标签页,google不能访问只能先换别的了,firefox也挺不 ...

  5. 用AutoHotKey彻底解决“Ctrl键+鼠标滚动”时的缩放问题

    “Ctrl键+鼠标滚动”会造成代码编辑窗口的字体缩放,这是自Visual Studio 2010以来引入的一个新特性,也是一个恼人的问题,详见VS2010中尴尬的代码窗口缩放功能. 于是,每次安装Vi ...

  6. react 热替换 ([HMR])

    react 热替换 ([HMR]) 热替换好多地方可以用到,目前比较流行的用法是搭配React和webpack实现在不刷新页面的情况下对模块的增删改.在给项目添加热替换功能的时候,可以说是踩了各种坑, ...

  7. php判断浏览器是不是IE

    1.$_SERVER['HTTP_USER_AGENT']和strpos 2.打印结果 谷歌: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Appl ...

  8. 在Raspbian Stretch系统上设置Home Assistant开机启动

    较新的Linux发行版趋向于用systemd管理守护进程,如果您不确定系统是否正在使用systemd,您可以使用以下命令进行检查: -o comm= 如果上述命令返回字符串systemd,说明系统正在 ...

  9. RPC调用与GC垃圾回收

    RPC调用 多个服务协同完成一次业务时,由于业务约束(如红包不符合使用条件.账户余额不足等).系统故障(如网络或系统超时或中断.数据库约束不满足等),都可能造成服务处理过程在任何一步无法继续,使数据处 ...

  10. 在netty3.x中存在两种线程:boss线程和worker线程。

    在netty 3.x 中存在两种线程:boss线程和worker线程.