LINUX CentOS 8 systemctl firewall 防火墙开启/关闭 命令

[[email protected] ~]#firewall-cmd --state

not running
[[email protected] hadoop]# systemctl is-enabled firewalld.service;echo $?      (查看服务是否开机启动)
enabled
0
[[email protected] hadoop]# systemctl disable firewalld.service (开机 不要 自动开)
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

[[email protected] hadoop]# systemctl is-enabled firewalld.service;echo $?
disabled
1

检查防火墙状态:

<pre>[[email protected] hadoop]# systemctl status firewalld.service
<font color="#8AE234"><b>●</b></font> firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: <font color="#8AE234"><b>active (running)</b></font> since Sat 2020-04-11 15:52:36 CST; 1h 50min ago
     Docs: man:firewalld(1)
 Main PID: 1109 (firewalld)
    Tasks: 2 (limit: 23821)
   Memory: 32.0M
   CGroup: /system.slice/firewalld.service
           └─1109 /usr/libexec/platform-python -s /usr/sbin/firewalld --nofork --nopid

Apr 11 15:52:33 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
Apr 11 15:52:36 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
</pre>

关闭防火墙:


[[email protected] hadoop]# systemctl stop firewalld.service

[[email protected] hadoop]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Sat 2020-04-11 17:44:32 CST; 7s ago
     Docs: man:firewalld(1)
  Process: 1109 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 1109 (code=exited, status=0/SUCCESS)

Apr 11 15:52:33 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
Apr 11 15:52:36 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
Apr 11 17:44:31 bigdata systemd[1]: Stopping firewalld - dynamic firewall daemon...
Apr 11 17:44:32 bigdata systemd[1]: Stopped firewalld - dynamic firewall daemon.

所有:

[[email protected] hadoop]# systemctl list-unit-files
UNIT FILE                                  STATE
proc-sys-fs-binfmt_misc.automount          static
-.mount                                    generated
boot.mount                                 generated
dev-hugepages.mount                        static
dev-mqueue.mount                           static
proc-fs-nfsd.mount                         static
proc-sys-fs-binfmt_misc.mount              static
sys-fs-fuse-connections.mount              static
sys-kernel-config.mount                    static
sys-kernel-debug.mount                     static
tmp.mount                                  disabled
var-lib-machines.mount                     static
var-lib-nfs-rpc_pipefs.mount               static
cups.path                                  enabled
ostree-finalize-staged.path                disabled
systemd-ask-password-console.path          static
systemd-ask-password-plymouth.path         static
systemd-ask-password-wall.path             static
session-10.scope                           transient
session-12.scope                           transient
session-13.scope                           transient
session-14.scope                           transient
session-2.scope                            transient
session-6.scope                            transient
session-c1.scope                           transient
accounts-daemon.service                    enabled
alsa-restore.service                       static
alsa-state.service                         static
anaconda-direct.service                    static
anaconda-nm-config.service                 static
anaconda-noshell.service                   static
anaconda-pre.service                       static
anaconda-[email protected]                    static
anaconda-sshd.service                      static
anaconda-[email protected]                     static
anaconda.service                           static
arp-ethers.service                         disabled
atd.service                                enabled
auditd.service                             enabled
auth-rpcgss-module.service                 static
[email protected]                            enabled
avahi-daemon.service                       enabled
binfmt_misc.service                        generated
blivet.service                             static
blk-availability.service                   disabled
bluetooth.service                          enabled
bolt.service                               static
brltty.service                             disabled
btattach-[email protected]                      static
canberra-system-bootup.service             disabled
canberra-system-shutdown-reboot.service    disabled
canberra-system-shutdown.service           disabled
chrony-[email protected]                     static
chrony-wait.service                        disabled
chronyd.service                            disabled
clean-mount-[email protected]                 static
cockpit-motd.service                       static
cockpit.service                            static
colord.service                             static
configure-[email protected]                 static
console-getty.service                      disabled
container-[email protected]                   static
cpupower.service                           disabled
crond.service                              enabled
cups-browsed.service                       disabled
cups.service                               enabled
dbus-org.bluez.service                     enabled
dbus-org.fedoraproject.FirewallD1.service  enabled
dbus-org.freedesktop.Avahi.service         enabled
dbus-org.freedesktop.hostname1.service     static
dbus-org.freedesktop.import1.service       static
dbus-org.freedesktop.locale1.service       static
dbus-org.freedesktop.login1.service        static
dbus-org.freedesktop.machine1.service      static
dbus-org.freedesktop.ModemManager1.service enabled
dbus-org.freedesktop.nm-dispatcher.service enabled
dbus-org.freedesktop.portable1.service     static
dbus-org.freedesktop.timedate1.service     enabled
dbus.service                               static
debug-shell.service                        disabled
display-manager.service                    enabled
dm-event.service                           static
dnf-makecache.service                      static
dnsmasq.service                            disabled
dracut-cmdline.service                     static
dracut-initqueue.service                   static
dracut-mount.service                       static
dracut-pre-mount.service                   static
dracut-pre-pivot.service                   static
dracut-pre-trigger.service                 static
dracut-pre-udev.service                    static
dracut-shutdown.service                    static
ebtables.service                           disabled
emergency.service                          static
firewalld.service                          enabled
flatpak-system-helper.service              static
fprintd.service                            static
fstrim.service                             static
fwupd-offline-update.service               static
fwupd.service                              static
gdm.service                                enabled
geoclue.service                            static
[email protected]                             enabled
grub-boot-indeterminate.service            static
gssproxy.service                           disabled
halt-local.service                         static
hypervfcopyd.service                       static
hypervkvpd.service                         static
hypervvssd.service                         static
iio-sensor-proxy.service                   static
import-state.service                       enabled
initial-setup-reconfiguration.service      disabled
initial-setup.service                      disabled
initrd-cleanup.service                     static
initrd-parse-etc.service                   static
initrd-switch-root.service                 static
initrd-udevadm-cleanup-db.service          static
instperf.service                           static
io.podman.service                          disabled
ip6tables.service                          disabled
iprdump.service                            disabled
iprinit.service                            disabled
iprupdate.service                          disabled
iptables.service                           disabled
irqbalance.service                         enabled
iscsi-shutdown.service                     static
iscsi.service                              enabled
iscsid.service                             disabled
iscsiuio.service                           disabled
jexec.service                              generated
kdump.service                              enabled
kmod-static-nodes.service                  static
kpatch.service                             disabled
ksm.service                                enabled
ksmtuned.service                           enabled
ldconfig.service                           static
libstoragemgmt.service                     enabled
libvirtd.service                           enabled
loadmodules.service                        enabled
lvm2-lvmpolld.service                      static
lvm2-monitor.service                       enabled
lvm2-[email protected]                       static
man-db-cache-update.service                static
mcelog.service                             enabled
mdadm-grow-[email protected]               static
mdadm-last-[email protected]                 static
mdcheck_continue.service                   static
mdcheck_start.service                      static
[email protected]                             static
mdmonitor-oneshot.service                  static
mdmonitor.service                          enabled
messagebus.service                         static
microcode.service                          enabled
mlocate-updatedb.service                   static
ModemManager.service                       enabled
multipathd.service                         enabled
ndctl-monitor.service                      disabled
netcf-transaction.service                  disabled
NetworkManager-dispatcher.service          enabled
NetworkManager-wait-online.service         enabled
NetworkManager.service                     enabled
nfs-blkmap.service                         disabled
nfs-convert.service                        enabled
nfs-idmapd.service                         static
nfs-mountd.service                         static
nfs-server.service                         disabled
nfs-utils.service                          static
nftables.service                           disabled
nis-domainname.service                     enabled
numad.service                              disabled
oddjobd.service                            disabled
ostree-finalize-staged.service             static
ostree-prepare-root.service                static
ostree-remount.service                     disabled
packagekit-offline-update.service          static
packagekit.service                         static
plymouth-halt.service                      static
plymouth-kexec.service                     static
plymouth-poweroff.service                  static
plymouth-quit-wait.service                 static
plymouth-quit.service                      static
plymouth-read-write.service                static
plymouth-reboot.service                    static
plymouth-start.service                     static
plymouth-switch-root.service               static
polkit.service                             static
psacct.service                             disabled
qemu-guest-agent.service                   disabled
qemu-pr-helper.service                     static
quotaon.service                            static
radvd.service                              disabled
ras-mc-ctl.service                         disabled
rasdaemon.service                          disabled
rc-local.service                           static
rdisc.service                              disabled
rdma-load-[email protected]                 static
rdma-ndd.service                           static
rdma.service                               disabled
realmd.service                             static
rescue.service                             static
rngd.service                               enabled
rpc-gssd.service                           static
rpc-statd-notify.service                   static
rpc-statd.service                          static
rpcbind.service                            enabled
rsyslog.service                            enabled
rtkit-daemon.service                       enabled
saslauthd.service                          disabled
selinux-autorelabel-mark.service           enabled
selinux-autorelabel.service                static
serial-get[email protected]                      disabled
smartd.service                             enabled
speech-dispatcherd.service                 disabled
spice-vdagentd.service                     indirect
sshd-[email protected]                       disabled
sshd.service                               enabled
[email protected]                              static
sssd-autofs.service                        indirect
sssd-kcm.service                           indirect
sssd-nss.service                           indirect
sssd-pac.service                           indirect
sssd-pam.service                           indirect
sssd-ssh.service                           indirect
sssd-sudo.service                          indirect
sssd.service                               enabled
switcheroo-control.service                 disabled
syslog.service                             enabled
system-update-cleanup.service              static
systemd-ask-password-console.service       static
systemd-ask-password-plymouth.service      static
systemd-ask-password-wall.service          static
systemd-[email protected]                 static
systemd-binfmt.service                     static
systemd-[email protected]                  static
systemd-exit.service                       static
systemd-firstboot.service                  static
systemd-fsck-root.service                  static
systemd-[email protected]                      static
systemd-halt.service                       static
systemd-hibernate-[email protected]          static
systemd-hibernate.service                  static
systemd-hostnamed.service                  static
systemd-hwdb-update.service                static
systemd-hybrid-sleep.service               static
systemd-importd.service                    static
systemd-initctl.service                    static
systemd-journal-catalog-update.service     static
systemd-journal-flush.service              static
systemd-journald.service                   static
systemd-kexec.service                      static
systemd-localed.service                    static
systemd-logind.service                     static
systemd-machine-id-commit.service          static
systemd-machined.service                   static
systemd-modules-load.service               static
systemd-[email protected]                    disabled
systemd-portabled.service                  static
systemd-poweroff.service                   static
systemd-quotacheck.service                 static
systemd-random-seed.service                static
systemd-reboot.service                     static
systemd-remount-fs.service                 static
systemd-resolved.service                   disabled
systemd-rfkill.service                     static
systemd-suspend-then-hibernate.service     static
systemd-suspend.service                    static
systemd-sysctl.service                     static
systemd-sysusers.service                   static
systemd-timedated.service                  masked
systemd-tmpfiles-clean.service             static
systemd-tmpfiles-setup-dev.service         static
systemd-tmpfiles-setup.service             static
systemd-udev-settle.service                static
systemd-udev-trigger.service               static
systemd-udevd.service                      static
systemd-update-done.service                static
systemd-update-utmp-runlevel.service       static
systemd-update-utmp.service                static
systemd-user-sessions.service              static
systemd-vconsole-setup.service             static
systemd-volatile-root.service              static
tcsd.service                               disabled
[email protected]                             static
timedatex.service                          enabled
tuned.service                              enabled
udisks2.service                            enabled
unbound-anchor.service                     static
upower.service                             disabled
[email protected]                    static
usbmuxd.service                            static
user-runtime-dir@.service                  static
[email protected]                              static
vdo.service                                enabled
vgauthd.service                            enabled
virtlockd.service                          indirect
virtlogd.service                           indirect
vmtoolsd-init.service                      disabled
vmtoolsd.service                           enabled
wacom-[email protected]                 static
wpa_supplicant.service                     disabled
zram.service                               static
machine.slice                              static
user.slice                                 static
avahi-daemon.socket                        enabled
cockpit.socket                             disabled
cups.socket                                enabled
dbus.socket                                static
dm-event.socket                            enabled
io.podman.socket                           disabled
iscsid.socket                              enabled
iscsiuio.socket                            enabled
lvm2-lvmpolld.socket                       enabled
multipathd.socket                          enabled
qemu-pr-helper.socket                      disabled
rpcbind.socket                             enabled
spice-vdagentd.socket                      static
sshd.socket                                disabled
sssd-autofs.socket                         disabled
sssd-kcm.socket                            enabled
sssd-nss.socket                            disabled
sssd-pac.socket                            disabled
sssd-pam-priv.socket                       disabled
sssd-pam.socket                            disabled
sssd-ssh.socket                            disabled
sssd-sudo.socket                           disabled
syslog.socket                              static
systemd-coredump.socket                    static
systemd-initctl.socket                     static
systemd-journald-audit.socket              static
systemd-journald-dev-log.socket            static
systemd-journald.socket                    static
systemd-rfkill.socket                      static
systemd-udevd-control.socket               static
systemd-udevd-kernel.socket                static
virtlockd-admin.socket                     disabled
virtlockd.socket                           enabled
virtlogd-admin.socket                      disabled
virtlogd.socket                            enabled
dev-mapper-cl\x2dswap.swap                 generated
anaconda.target                            static
basic.target                               static
bluetooth.target                           static
cryptsetup-pre.target                      static
cryptsetup.target                          static
ctrl-alt-del.target                        disabled
default.target                             indirect
emergency.target                           static
exit.target                                disabled
final.target                               static
getty-pre.target                           static
getty.target                               static
graphical.target                           indirect
halt.target                                disabled
hibernate.target                           static
hybrid-sleep.target                        static
initrd-fs.target                           static
initrd-root-device.target                  static
initrd-root-fs.target                      static
initrd-switch-root.target                  static
initrd.target                              static
iprutils.target                            disabled
kexec.target                               disabled
local-fs-pre.target                        static
local-fs.target                            static
machines.target                            disabled
multi-user.target                          static
network-online.target                      static
network-pre.target                         static
network.target                             static
nfs-client.target                          enabled
nss-lookup.target                          static
nss-user-lookup.target                     static
paths.target                               static
poweroff.target                            disabled
printer.target                             static
rdma-hw.target                             static
reboot.target                              disabled
remote-cryptsetup.target                   disabled
remote-fs-pre.target                       static
remote-fs.target                           enabled
rescue.target                              static
rpc_pipefs.target                          static
rpcbind.target                             static
runlevel0.target                           disabled
runlevel1.target                           static
runlevel2.target                           static
runlevel3.target                           static
runlevel4.target                           static
runlevel5.target                           indirect
runlevel6.target                           disabled
selinux-autorelabel.target                 static
shutdown.target                            static
sigpwr.target                              static
sleep.target                               static
slices.target                              static
smartcard.target                           static
sockets.target                             static
sound.target                               static
sshd-keygen.target                         static
suspend-then-hibernate.target              static
suspend.target                             static
swap.target                                static
sysinit.target                             static
system-update-pre.target                   static
system-update.target                       static
time-sync.target                           static
timers.target                              static
umount.target                              static
virt-guest-shutdown.target                 static
chrony-[email protected]                       disabled
dnf-makecache.timer                        enabled
fstrim.timer                               disabled
mdadm-last-[email protected]                   static
mdcheck_continue.timer                     static
mdcheck_start.timer                        disabled
mdmonitor-oneshot.timer                    disabled
mlocate-updatedb.timer                     disabled
systemd-tmpfiles-clean.timer               static
unbound-anchor.timer                       enabled  

419 unit files listed.
lines 395-422/422 (END)

原文地址:https://www.cnblogs.com/watermarks/p/12681224.html

时间: 2024-07-31 14:11:39

LINUX CentOS 8 systemctl firewall 防火墙开启/关闭 命令的相关文章

Linux虚拟机SSH服务、防火墙开启关闭

1.查看SSH服务 serveice sshd status --> Checking for service sshd running 2.开启SSH服务 service sshd start --> starting SSH daemon 3.临时关闭防火墙(环境重启之后,防火墙又会关闭) rcSuSEfirewall2 stop 4.永久关闭防火墙 chkconfig SuSEfirewall2_init off chkconfig SuSEfirewall2_setup off 分操作

Centos中iptables和firewall防火墙开启、关闭、查看状态、基本设置等(转)

iptables防火墙 1.基本操作 # 查看防火墙状态 service iptables status # 停止防火墙 service iptables stop # 启动防火墙 service iptables start # 重启防火墙 service iptables restart # 永久关闭防火墙 chkconfig iptables off # 永久关闭后重启 chkconfig iptables on 2.查看防火墙状态,防火墙处于开启状态并且只开放了22端口 3.开启80端口

centos 7 and 6 防火墙 开启端口 并测试

1.防火墙 CentOS升级到7之后,发现无法使用iptables控制Linuxs的端口,google之后发现Centos 7使用firewalld代替了原来的iptables.下面记录如何使用firewalld开放Linux端口: 查看防火墙状态 systemctl status firewalld 开启防火墙 systemctl start firewalld 关闭防火墙 systemctl stop firewalld 查看当前firewall状态 firewall-cmd --state

linux查看防火墙状态及开启关闭命令(转)

存在以下两种方式: 一.service方式 查看防火墙状态: [[email protected] ~]# service iptables status iptables:未运行防火墙. 开启防火墙: [[email protected] ~]# service iptables start 关闭防火墙: [[email protected] ~]# service iptables stop 二.iptables方式 先进入init.d目录,命令如下: [[email protected]

linux查看防火墙状态及开启关闭命令

查看防火墙状态:  [[email protected] ~]# service iptables status iptables:未运行防火墙. 开启防火墙: [[email protected] ~]# service iptables start 关闭防火墙: [[email protected] ~]# service iptables stop 原文地址:https://www.cnblogs.com/dk1024/p/11747788.html

centos 7配置firewall防火墙的地址伪装和端口转发实例

环境如下图所示,网关服务器和网站服务器都采用centos 7操作系统,网关服务器安装3块千兆网卡,分别连接Internet.企业内网.网站服务器. 网关服务器连接互联网卡ens33配置为公网IP地址,分配到firewall的external区域:连接内网网卡ens37地址为192.168.1.1,分配到firewall的trusted区域:连接服务器网卡ens38地址为192.168.2.1,分配到firewall的DMZ区域. 网站服务器和网关服务器都通过SSH来远程管理,为了安全,将SSH默

CentOS 7.0 Firewall防火墙配置

转自:http://blog.csdn.net/qq1113130712/article/details/70156508 CentOS 7.0防火墙配置参数说明 启动停止 获取firewall状态 systemctl status firewalld.service firewall-cmd --state 开启停止防火墙 开机启动:systemctl enable firewalld.service 启动:systemctl start firewalld.service 停止:system

Linux centos 下 eclipse 打开文件时关闭

原文地址:http://processors.wiki.ti.com/index.php/Linux_Host_Support#cairo-misc.c:380:_cairo_operator_bounded_by_source:_Assertion_.60NOT_REACHED.27_failed http://processors.wiki.ti.com/index.php/Linux_Host_Support 现象描述:在 centos 系统下,打开eclipse后,打开文件时,eclip

Centos查看端口占用和开启端口命令

Centos查看端口占用情况命令,比如查看80端口占用情况使用如下命令: lsof -i tcp:80 列出所有端口 netstat -ntlp 1.开启端口(以80端口为例) 方法一: /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT 写入修改 /etc/init.d/iptables save 保存修改 service iptables restart 重启防火墙,修改生效 方法二: vi /etc/sysconfig/iptables