Yuri Slobodyanyuk Blog on Information Security 2024年09月12日
Grab bag of IPF firewall commands for FreeBSD and Solaris 10
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文介绍了在FreeBSD、OpenBSD和Solaris系统中使用Pffirewall的相关内容,包括启用和禁用防火墙、永久设置、规则操作及展示命令等。

🧨Pffirewall在多种系统中的启用与禁用方法。如在FreeBSD、OpenBSD中通过修改配置文件实现永久设置;通过特定命令启用或禁用实时数据包过滤等。

📜详细阐述了Pffirewall的规则操作。如Flush命令可移除运行中的数据包过滤器的所有活动规则;通过特定命令加载规则文件并检查语法等。

📄介绍了规则文件中的规则顺序,包括选项、规范化、排队、转换和过滤规则等,并展示了一些相关命令及其作用。

Nothing new here , just a round-up of the commands/configs I happen to need from time to time. Google probably has better references for that.I talk about Pf firewall used in FreeBSD, OpenBSD and Solaris systems.

Enable and disable firewall:

pfctl –e

Enable packet filter real time

pfctl –ef /etc/pf.conf

Enable packet filter and load rules from /etc/pf.conf

pfctl –d

Disable packet filter

Enable/disable permanently to survive reboot

OpenBSD :

/etc/rc.conf.local:      pf=YES      pf_rules=/etc/pf.conf

FreeBSD:

/etc/default/rc.conf:      pf_enable="YES"     pf_rules="/etc/pf.conf"      pf_program="/sbin/pfctl"      pflog_enable="YES"      pflog_logfile="/var/log/pflog"

Working with rules.

pfctl –F all

Flush (remove) all the active rules from the running packet filter , means PERMIT ANY ANY.

pfctl –n –f /etc/pf.conf

just parse rules from file , not actually loading them, to check syntax

pfctl -f /etc/pf.conf

Load rules from file

Order of rules in the file :options, normalization, queuing, translation, and filtering rules.

Show commands.

pfctl –s info

Show filter information

pfctl -s rules

Show the currently loaded filter rules

pfctl -s state

Show the contents of the state table.

pfctl -s all

Show all of the above

Simplest set of rules - block all the incoming but ssh, allow all the outgoing from the server:

block in all   pass out all keep state   pass in   proto tcp from any to any port 22

Follow me on https://www.linkedin.com/in/yurislobodyanyuk/ not to miss what I publish on Linkedin, Github, blog, and more.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

Pffirewall 防火墙配置 规则操作
相关文章