先明确iptables和UFW之间的关系才行...
iptables是后端数据库,纪录着所有是否允许端口的信息 可用如下命令查看
iptables -L
UFW是上述数据库的前端,提供友好的,很显然很不友好....
iptables
Iptables is the database of firewall rules and is the actual firewall used in Linux systems. The traditional interface for configuring iptables in Linux systems is the command-line interface terminal. The other utilities in this section simplify the manipulation of the iptables database.
UFW
UFW (Uncomplicated Firewall) is a front-end for iptables and is particularly well-suited for host-based firewalls. UFW was developed specifically for Ubuntu (but is available in other distributions), and is also configured from the terminal.
Gufw is a graphical front-end to UFW, and is recommended for beginners.
UFW was introduced in Ubuntu 8.04 LTS (Hardy Heron), and is available by default in all Ubuntu installations after 8.04 LTS.
Guarddog
Guarddog is a front-end for iptables that functions in KDE-based desktops, such as Kubuntu. It has a greater deal of complexity (and flexibility, perhaps).
解决方法
只需要在iptables中加上相应的规则即可
(此处有坑)
iptables -A 和 iptables -I 命令是不同的 ,需要以如下命令添加才可行
iptables -I INPUT -p tcp --dport 21 -j ACCEPT
//即为开放tcp 21端口