LINUX CentOS 8 systemctl firewall 防火墙开启/关闭 命令
Posted One is never too old to learn.
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LINUX CentOS 8 systemctl firewall 防火墙开启/关闭 命令相关的知识,希望对你有一定的参考价值。
[root@localhost ~]#firewall-cmd --state
not running
[root@bigdata hadoop]# systemctl is-enabled firewalld.service;echo $? (查看服务是否开机启动) enabled 0 [root@bigdata hadoop]# systemctl disable firewalld.service (开机 不要 自动开) Removed /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@bigdata hadoop]# systemctl is-enabled firewalld.service;echo $?
disabled
1
检查防火墙状态:
<pre>[root@bigdata 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>
关闭防火墙:
[root@bigdata hadoop]# systemctl stop firewalld.service
[root@bigdata 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.
所有:
[root@bigdata 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-shell@.service static anaconda-sshd.service static anaconda-tmux@.service static anaconda.service static arp-ethers.service disabled atd.service enabled auditd.service enabled auth-rpcgss-module.service static autovt@.service 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-bcm@.service static canberra-system-bootup.service disabled canberra-system-shutdown-reboot.service disabled canberra-system-shutdown.service disabled chrony-dnssrv@.service static chrony-wait.service disabled chronyd.service disabled clean-mount-point@.service static cockpit-motd.service static cockpit.service static colord.service static configure-printer@.service static console-getty.service disabled container-getty@.service 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 getty@.service 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-pvscan@.service static man-db-cache-update.service static mcelog.service enabled mdadm-grow-continue@.service static mdadm-last-resort@.service static mdcheck_continue.service static mdcheck_start.service static mdmon@.service 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-modules@.service 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-getty@.service disabled smartd.service enabled speech-dispatcherd.service disabled spice-vdagentd.service indirect sshd-keygen@.service disabled sshd.service enabled sshd@.service 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-backlight@.service static systemd-binfmt.service static systemd-coredump@.service static systemd-exit.service static systemd-firstboot.service static systemd-fsck-root.service static systemd-fsck@.service static systemd-halt.service static systemd-hibernate-resume@.service 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-nspawn@.service 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 teamd@.service static timedatex.service enabled tuned.service enabled udisks2.service enabled unbound-anchor.service static upower.service disabled usb_modeswitch@.service static usbmuxd.service static user-runtime-dir@.service static user@.service static vdo.service enabled vgauthd.service enabled virtlockd.service indirect virtlogd.service indirect vmtoolsd-init.service disabled vmtoolsd.service enabled wacom-inputattach@.service 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-clx2dswap.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-dnssrv@.timer disabled dnf-makecache.timer enabled fstrim.timer disabled mdadm-last-resort@.timer 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)
以上是关于LINUX CentOS 8 systemctl firewall 防火墙开启/关闭 命令的主要内容,如果未能解决你的问题,请参考以下文章
linux centos7 常用命令systemctl替换service
Linux CentOS7.0 (04)systemctl vs chkconfigservice
Linux基于CentOS通过Systemctl 设置开机启动/永久性关闭服务