如何启动/停止iptables?

在学习关于iptables的一些新东西时,我无法通过这个。 虽然我想开始,但它的说法是

root@badfox:~# iptables -L -n -v Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination root@badfox:~# service iptables stop iptables: unrecognized service root@badfox:~# service iptables start iptables: unrecognized service 

资料来源: http : //www.cyberciti.biz/tips/linux-iptables-examples.html

为什么我会这样?

编辑:所以我的防火墙已经启动,但为什么我没有得到输出,就像我在第一次训练中的源链接链接中提到的那样。

这是我的输出

 root@badfox:~# sudo start ufw start: Job is already running: ufw root@badfox:~# iptables -L -n -v Chain INPUT (policy ACCEPT 4882 packets, 2486K bytes) pkts bytes target prot opt in out source destination Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 5500 packets, 873K bytes) pkts bytes target prot opt in out source destination root@badfox:~# 

Uncomplicated Firewall或ufw是默认情况下在Ubuntu上提供的iptables配置工具。 因此,如果你想启动或停止ufw服务,你必须做这样的事情

 #To stop $ sudo service ufw stop ufw stop/waiting #To start $ sudo service ufw start ufw start/running 

关于您没有收到源中显示的输出的原因 。 它清楚地指出,您收到的输出是针对非活动防火墙的,即没有设置任何规则。 所以尝试在iptables设置一些规则。 这是iptables上的Ubuntu Wiki,它向您展示如何设置,编辑它们等。

service命令在基于RedHat的系统上运行得非常好,甚至在采用systemd的Centos 7上也是如此。

因此,如果基于Debian的系统本身不考虑iptables服务,它仍然可能被认为是一个。 并且命令“service iptables restart”实际上非常有用,特别是当你想要iptables恢复’默认’规则时(意思是,使用主脚本;在centos / etc / sysconfig / iptables等)