Loaded:loaded(/usr/lib/systemd/system/iptables.service;enabled)Active: inactive

[root@localhost ~]# service iptables start

Redirecting to /bin/systemctl start  iptables.service

[root@localhost ~]# /bin/systemctl start  iptables.service

[root@localhost ~]# service iptables status

Redirecting to /bin/systemctl status  iptables.service

iptables.service- IPv4 firewall with iptables

   Loaded: loaded(/usr/lib/systemd/system/iptables.service; enabled)

   Active: inactive (dead)

         start condition failed at 2016-01-16 20:06:38 CST; 9s ago

615 09:00:49 localhost.localdomain systemd[1]: Started IPv4 firewall with...

623 09:24:07 localhost.localdomain systemd[1]: Stopped IPv4 firewall with...

623 09:24:17 localhost.localdomain systemd[1]: Stopped IPv4 firewall with...

623 09:31:26 localhost.localdomain systemd[1]: Stopped IPv4 firewall with...

623 09:31:35 localhost.localdomain systemd[1]: Stopped IPv4 firewall with...

623 10:54:34 localhost.localdomain systemd[1]: Started IPv4 firewall with...

623 10:54:42 localhost.localdomain systemd[1]: Started IPv4 firewall with...

114 21:11:24 localhost.localdomain systemd[1]: Started IPv4 firewall with...

116 20:06:24 localhost.localdomain systemd[1]: Started IPv4 firewall with...

116 20:06:38 localhost.localdomain systemd[1]: Started IPv4 firewall with...

[root@localhost ~]#

 

解决办法:

[root@localhost ~]# cd /etc/sysconfig

[root@localhost sysconfig]# ls

atd              ip6tables-config  nfs           saslauthd

authconfig       iptables-config   nfs~           selinux

cbq              iptables-config~  pluto         sendmail

console          irda              prelink        smartmontools

crond            irqbalance        radvd          sshd

ebtables-config  kernel            raid-check     svnserve

firewalld        libvirtd          rdisc          sysstat

glusterd         libvirt-guests    readonly-root  sysstat.ioconf

glusterfsd       man-db            rpcbind        system-config-users

grub             modules           rsyncd         virtlockd

htcacheclean     netconsole        rsyslog        vncservers

httpd            network           run-parts      wpa_supplicant

init             network-scripts   samba

[root@localhost sysconfig]#

 

iptables-config改为iptables

[root@localhost sysconfig]# mv iptables-config iptables

命令初始化配置文件

[root@localhost sysconfig]#iptables-save >/etc/sysconfig/iptables

然后重启防火墙,执行添加规则命令

[root@localhost sysconfig]#iptables -I INPUT-p tcp �Cdport 3306 -j ACCEPT

重新启动防火墙

[root@localhost sysconfig]#/bin/systemctlstart  iptables.service

查看状态,启动成功

[root@localhost sysconfig]#service iptablesstatus

Redirecting to /bin/systemctl status  iptables.service

iptables.service - IPv4 firewall withiptables

  Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled)

  Active: active (exited) since 2016-01-16 16:50:17 CST; 3h 29min ago

 Process: 24462 ExecStop=/usr/libexec/iptables/iptables.init stop(code=exited, status=0/SUCCESS)

 Process: 24596 ExecStart=/usr/libexec/iptables/iptables.init start(code=exited, status=0/SUCCESS)

 

116 16:50:17 localhost.cs1cloud.internal iptables.init[24596]: iptabl...

116 16:50:17 localhost.cs1cloud.internal systemd[1]: Started IPv4 fir...

116 16:50:23 localhost.cs1cloud.internal systemd[1]: Started IPv4 fir...

 

查看端口号,3306端口已经打开

[root@localhost ~]#iptables -L -n

Chain INPUT (policy ACCEPT)

target    prot opt source              destination

ACCEPT    all  --  0.0.0.0/0            0.0.0.0/0

ACCEPT    all  --  0.0.0.0/0            0.0.0.0/0

ACCEPT    tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:22

ACCEPT    tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:3306

 

Chain FORWARD (policy ACCEPT)

target    prot opt source               destination

 

Chain OUTPUT (policy ACCEPT)

target    prot opt source              destination


本文出自 “DOSOM” 博客,谢绝转载!

你可能感兴趣的:(inactive,Active:)