Mip*_*hix 42 iptables firewall ufw
Ufw 有一个命令列出配置文件,您可以进一步探索其配置文件定义
$ ufw app list
Run Code Online (Sandbox Code Playgroud)
和
$ ufw app PROFILE {app profile title}
Run Code Online (Sandbox Code Playgroud)
我想知道如何为未定义的程序创建配置文件,例如虚拟机,并让该配置文件运行与我为 Ubuntu 发行版提供的 iptables 相同的定义。
我不仅要尝试使用 Ubuntu 防火墙来为我的虚拟机提供服务。我也很想知道如何为没有附带的应用程序创建配置文件。
小智 51
要回答真正的问题,关于如何创建自己的应用程序文件,您只需要知道它使用的是 windows INI 文件格式(糟糕)。
[appname]
title=1-liner here
description=a longer line here
ports=1,2,3,4,5,6,7,8,9,10,30/tcp|50/udp|53
Run Code Online (Sandbox Code Playgroud)
端口行可以指定多个端口,用 /udp 或 /tcp 来限制协议,否则默认为两者。您必须用 | 拆分协议部分。
因此,对于我制作的一组真实示例:
[puppet]
title=puppet configuration manager
description=Puppet Open Source from http://www.puppetlabs.com/
ports=80,443,8140/tcp
[AMANDA]
title=AMANDA Backup
description=AMANDA the Advanced Maryland Automatic Network Disk Archiver
ports=10080
Run Code Online (Sandbox Code Playgroud)
您可以在一个文件中列出应用程序的多个版本,例如来自 apache 的这个:
===start of apache2.2-common file===
[Apache]
title=Web Server
description=Apache v2 is the next generation of the omnipresent Apache web server.
ports=80/tcp
[Apache Secure]
title=Web Server (HTTPS)
description=Apache v2 is the next generation of the omnipresent Apache web server.
ports=443/tcp
[Apache Full]
title=Web Server (HTTP,HTTPS)
description=Apache v2 is the next generation of the omnipresent Apache web server.
ports=80,443/tcp
===end of file===
Run Code Online (Sandbox Code Playgroud)
定义应用程序文件后,将其放入/etc/ufw/applications.d,然后告诉 ufw 重新加载应用程序定义
ufw app update appname
ufw app info appname
Run Code Online (Sandbox Code Playgroud)
将它与类似的东西一起使用:
ufw allow from 192.168.1.10 to any app amanda
ufw allow amanda
Run Code Online (Sandbox Code Playgroud)
假设 192.168.1.10 是您的 amanda 服务器的 IP。
Set*_*eth 11
它实际上都在“应用程序集成”部分下的联机帮助页中。
基本语法是:
ufw allow <app_name>
Run Code Online (Sandbox Code Playgroud)
或者您可以使用扩展语法更具体:
ufw allow from <some_address> to any app <app_name>
Run Code Online (Sandbox Code Playgroud)
联机帮助页特别说明不要指定端口号:
您不应使用任何一种语法指定协议,并且使用扩展语法,请使用 app 代替 port 子句。
这可能意味着它将允许<app_name>使用它想要的任何端口。
其他有用的命令:
ufw app info <app_name>
Run Code Online (Sandbox Code Playgroud)
其中列出了关于<app_name>的个人资料的信息。
ufw app update <app_name>
Run Code Online (Sandbox Code Playgroud)
其中更新了<app_name>个人资料。您可以使用all更新所有应用程序配置文件。
您可以使用:
ufw app update --add-new <app_name>
Run Code Online (Sandbox Code Playgroud)
命令来添加一个新的配置文件<app_name>并更新它,遵循你用ufw app default <policy>.
应用程序配置文件存储在/etc/ufw/applications.d有时/etc/services。
有关更多信息,请参阅man ufw。