注:本文转载自cnblogs:一天学点的文章《/etc/rc.d/init.d/iptables: No such file or directory 错误原因》
RedHat Enterprise Linux 7关闭防火墙方法
在之前的版本中关闭防火墙等服务的命令是
1 service iptables stop 2 3 /etc/init.d/iptables stop
在RHEL7中,其实没有这个服务
1 [root@rhel7 ~]# cat /etc/redhat-release 2 Red Hat Enterprise Linux Server release 7.0 (Maipo) 3 [root@rhel7 ~]# service iptables stop 4 Redirecting to /bin/systemctl stop iptables.service 5 [root@rhel7 ~]# /etc/init.d/iptables stop 6 -bash: /etc/init.d/iptables: No such file or directory
原来在RHEL7开始,使用systemctl工具来管理服务程序,包括了service和chkconfig
1 [root@rhel7 ~]# systemctl list-unit-files|grep enabled 2 cups.path enabled 3 abrt-ccpp.service enabled 4 abrt-oops.service enabled 5 abrt-vmcore.service enabled 6 abrt-xorg.service enabled 7 abrtd.service enabled 8 accounts-daemon.service enabled 9 atd.service enabled 10 auditd.service enabled 11 avahi-daemon.service enabled 12 bluetooth.service enabled 13 chronyd.service enabled 14 crond.service enabled 15 cups.service enabled 16 dbus-org.bluez.service enabled 17 dbus-org.fedoraproject.FirewallD1.service enabled 18 dbus-org.freedesktop.Avahi.service enabled 19 dbus-org.freedesktop.ModemManager1.service enabled 20 dbus-org.freedesktop.NetworkManager.service enabled 21 dbus-org.freedesktop.nm-dispatcher.service enabled 22 display-manager.service enabled 23 dmraid-activation.service enabled 24 firewalld.service enabled 25 firstboot-graphical.service enabled 26 gdm.service enabled 27 getty@.service enabled 28 hypervkvpd.service enabled 29 hypervvssd.service enabled 30 irqbalance.service enabled 31 iscsi.service enabled 32 ksm.service enabled 33 ksmtuned.service enabled 34 libstoragemgmt.service enabled 35 libvirtd.service enabled 36 lvm2-monitor.service enabled 37 mdmonitor.service enabled 38 microcode.service enabled 39 ModemManager.service enabled 40 multipathd.service enabled 41 NetworkManager-dispatcher.service enabled 42 NetworkManager.service enabled 43 nfs-lock.service enabled 44 packagekit-offline-update.service enabled 45 postfix.service enabled 46 rhsmcertd.service enabled 47 rngd.service enabled 48 rpcbind.service enabled 49 rsyslog.service enabled 50 rtkit-daemon.service enabled 51 smartd.service enabled 52 spice-vdagentd.service enabled 53 sshd.service enabled 54 sysstat.service enabled 55 systemd-readahead-collect.service enabled 56 systemd-readahead-drop.service enabled 57 systemd-readahead-replay.service enabled 58 tuned.service enabled 59 vmtoolsd.service enabled 60 avahi-daemon.socket enabled 61 cups.socket enabled 62 dm-event.socket enabled 63 iscsid.socket enabled 64 iscsiuio.socket enabled 65 lvm2-lvmetad.socket enabled 66 rpcbind.socket enabled 67 default.target enabled 68 graphical.target enabled 69 nfs.target enabled 70 remote-fs.target enabled
禁用防火墙
1 [root@rhel7 ~]# systemctl stop firewalld.service 2 [root@rhel7 ~]# systemctl disable firewalld.service 3 [root@rhel7 ~]# systemctl status firewalld.service 4 firewalld.service – firewalld – dynamic firewall daemon 5 Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled) 6 Active: inactive (dead) 7 8 Jul 29 22:25:43 rhel7 systemd[1]: Started firewalld – dynamic firewall daemon. 9 Jul 29 22:43:29 rhel7 systemd[1]: Stopping firewalld – dynamic firewall daemon… 10 Jul 29 22:43:29 rhel7 systemd[1]: Stopped firewalld – dynamic firewall daemon. 11 Jul 29 22:44:14 rhel7 systemd[1]: Stopped firewalld – dynamic firewall daemon. 12 Jul 29 22:44:15 rhel7 systemd[1]: Stopped firewalld – dynamic firewall daemon. 13 Jul 29 22:44:19 rhel7 systemd[1]: Starting firewalld – dynamic firewall daemon… 14 Jul 29 22:44:19 rhel7 systemd[1]: Started firewalld – dynamic firewall daemon. 15 Jul 29 22:44:21 rhel7 systemd[1]: Stopping firewalld – dynamic firewall daemon… 16 Jul 29 22:44:21 rhel7 systemd[1]: Stopped firewalld – dynamic firewall daemon. 17 Jul 29 22:44:32 rhel7 systemd[1]: Stopped firewalld – dynamic firewall daemon.
1 启动一个服务:systemctl start firewalld.service 2 关闭一个服务:systemctl stop firewalld.service 3 重启一个服务:systemctl restart firewalld.service 4 显示一个服务的状态:systemctl status firewalld.service 5 在开机时启用一个服务:systemctl enable firewalld.service 6 在开机时禁用一个服务:systemctl disable firewalld.service 7 查看服务是否开机启动:systemctl is-enabled firewalld.service;echo $? 8 查看已启动的服务列表:systemctl list-unit-files|grep enabled
批注:对于这个文章的提示,我不知道是没有得到操作要领还是怎么回事,反正标题的问题我没有得到解决。