如何启动/停止iptables?

rɑː*_*dʒɑ 20 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
Run Code Online (Sandbox Code Playgroud)

来源: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:~# 
Run Code Online (Sandbox Code Playgroud)

Nit*_*esh 33

无并发症的防火墙或者ufw是配置工具iptables自带默认Ubuntu上。所以如果你想启动或停止ufw服务,你必须做这样的事情

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

#To start
$ sudo service ufw start
ufw start/running
Run Code Online (Sandbox Code Playgroud)

关于为什么您没有收到源中所示的输出。它清楚地说明您收到的输出是针对非活动防火墙的,即未设置任何规则。所以尝试在iptables. 这是iptables上的Ubuntu Wiki,它向您展示了如何设置、编辑它们等。

  • 为了能够看到规则,您必须**插入规则**,请在此处完全阅读链接为“#4:插入防火墙规则”。 (2认同)