{"id":14382,"date":"2025-02-06T11:38:46","date_gmt":"2025-02-06T03:38:46","guid":{"rendered":"https:\/\/blog.pfchina.org\/?p=14382"},"modified":"2025-02-13T10:15:54","modified_gmt":"2025-02-13T02:15:54","slug":"pfsense%e9%98%b2%e7%81%ab%e5%a2%99pftop%e5%91%bd%e4%bb%a4%e8%a1%8c%e5%b7%a5%e5%85%b7%e4%bd%bf%e7%94%a8%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/blog.pfchina.org\/?p=14382","title":{"rendered":"pfSense\u3001OPNsense\u9632\u706b\u5899pftop\u5de5\u5177\u4f7f\u7528\u6559\u7a0b"},"content":{"rendered":"<p style=\"text-align: justify;\">pftop\u662f\u4e00\u4e2a\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u7528\u4e8e\u5b9e\u65f6\u76d1\u63a7\u548c\u663e\u793apfSense\u9632\u706b\u5899\u7684\u6d41\u91cf\u548c\u8fde\u63a5\u72b6\u6001\u3002\u5b83\u4e3b\u8981\u7528\u4e8e\u67e5\u770b\u6709\u5173 pf (Packet Filter) \u8fc7\u6ee4\u5668\u7684\u5404\u79cd\u7edf\u8ba1\u4fe1\u606f\uff0c\u5bf9\u76d1\u63a7\u7f51\u7edc\u6d41\u91cf\uff0c\u6392\u67e5\u7f51\u7edc\u6545\u969c\u975e\u5e38\u6709\u7528\u3002<\/p>\n<p style=\"text-align: justify;\">pfSense\u9632\u706b\u5899\u63d0\u4f9b\u4e86Web\u7aef\u7684\u63a7\u5236\u7a0b\u5e8f\uff0cOPNsense\u53ea\u63d0\u4f9b\u4e86\u547d\u4ee4\u884c\u547d\u4ee4\uff0c\u535a\u4e3b\u7f16\u5199\u4e86\u4e00\u4e2aWeb\u7aef\u7684\u63a7\u5236\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u70b9\u51fb<span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/blog.pfchina.org\/?p=14195\">\u8fd9\u91cc<\/a><\/span>\u4e0b\u8f7d\u4f7f\u7528<span style=\"color: #0000ff;\">\u3002<\/span>\u4e0b\u9762\u4ee5pfSense\u4e3a\u4f8b\u4ecb\u7ecdpftop\u7684\u4f7f\u7528\u65b9\u6cd5\u3002<\/p>\n<h2>\u529f\u80fd\u7279\u70b9<\/h2>\n<p>pftop\u53ef\u4ee5\u663e\u793a\u4ee5\u4e0b\u4fe1\u606f\uff1a<\/p>\n<ul>\n<li>\u6d41\u91cf\u7edf\u8ba1\uff1a\u4f20\u5165\u548c\u4f20\u51fa\u7684\u6d41\u91cf\uff1a\u53ef\u4ee5\u67e5\u770b\u6bcf\u4e2a\u8fde\u63a5\u7684\u6d41\u91cf\u7edf\u8ba1\uff0c\u5305\u62ec\u4f20\u5165\uff08ingress\uff09\u548c\u4f20\u51fa\uff08egress\uff09\u7684\u6570\u636e\u5305\u6570\u91cf\u548c\u5b57\u8282\u6570\u3002<\/li>\n<li>\u8fde\u63a5\u72b6\u6001\uff1apftop\u4f1a\u5217\u51fa\u5f53\u524d\u6240\u6709\u6d3b\u52a8\u7684\u8fde\u63a5\uff0c\u5305\u62ec\u6e90IP\u3001\u76ee\u6807IP\u3001\u7aef\u53e3\u3001\u534f\u8bae\u7b49\u4fe1\u606f\u3002\u6709\u52a9\u4e8e\u67e5\u770b\u54ea\u4e9b\u8fde\u63a5\u662f\u6d3b\u8dc3\u7684\uff0c\u54ea\u4e9b\u53ef\u80fd\u5b58\u5728\u5f02\u5e38\u6d41\u91cf\u3002<\/li>\n<li>\u8fde\u63a5\u8d85\u65f6\uff1a\u5b83\u663e\u793a\u8fde\u63a5\u7684\u751f\u547d\u5468\u671f\uff0c\u5e2e\u52a9\u4f60\u8bc6\u522b\u54ea\u4e9b\u8fde\u63a5\u53ef\u80fd\u7531\u4e8e\u8d85\u65f6\u6216\u88ab\u5173\u95ed\u800c\u4e2d\u65ad\u3002<\/li>\n<li>\u5339\u914d\u89c4\u5219\uff1apftop\u4f1a\u663e\u793a\u6570\u636e\u5305\u4e0e\u9632\u706b\u5899\u89c4\u5219\u7684\u5339\u914d\u60c5\u51b5\uff0c\u5e2e\u52a9\u4f60\u4e86\u89e3\u54ea\u4e9b\u89c4\u5219\u6b63\u5728\u88ab\u89e6\u53d1\u4ee5\u53ca\u76f8\u5e94\u7684\u6d41\u91cf\u60c5\u51b5\u3002<\/li>\n<li>\u534f\u8bae\u5206\u6790\uff1apftop\u80fd\u591f\u663e\u793a\u4e0d\u540c\u534f\u8bae\uff08\u5982TCP\u3001UDP\u3001ICMP\u7b49\uff09\u7684\u6570\u636e\u5305\u548c\u5b57\u8282\u6570\uff0c\u5e2e\u52a9\u4f60\u76d1\u63a7\u4e0d\u540c\u7c7b\u578b\u6d41\u91cf\u7684\u4f7f\u7528\u60c5\u51b5\u3002<\/li>\n<li>\u9ad8\u6d41\u91cf\u8fde\u63a5\uff1a\u5b83\u4f1a\u5217\u51fa\u6d88\u8017\u6700\u591a\u6d41\u91cf\u7684\u8fde\u63a5\uff0c\u5e2e\u52a9\u4f60\u5feb\u901f\u8bc6\u522b\u5e26\u5bbd\u6d88\u8017\u8f83\u5927\u7684\u8fde\u63a5\u3002<\/li>\n<li>\u72b6\u6001\u4fe1\u606f\uff1a\u63d0\u4f9b\u5173\u4e8epf\u9632\u706b\u5899\u7684\u72b6\u6001\u4fe1\u606f\uff0c\u4f8b\u5982\u8fc7\u6ee4\u5668\u7684\u72b6\u6001\u3001\u6d41\u91cf\u63a7\u5236\u3001\u4e22\u5305\u7b49\u3002<\/li>\n<\/ul>\n<h2>\u4f7f\u7528\u65b9\u6cd5<\/h2>\n<p>\u5bfc\u822a\u5230\u8bca\u65ad&gt;pfTop\u8fd0\u884c\u547d\u4ee4\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><a href=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2025\/02\/jt_2025-02-06_11-30-44.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-14394 size-full\" src=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2025\/02\/jt_2025-02-06_11-30-44.png\" alt=\"\" width=\"1697\" height=\"971\" \/><\/a><\/p>\n<h3>\u67e5\u770b<\/h3>\n<p>\u67e5\u770b\u9009\u9879\u53ef\u4ee5\u8ba9\u4f60\u6839\u636e\u4e0d\u540c\u7684\u6307\u6807\u663e\u793a\u6240\u9700\u8981\u7684\u67e5\u8be2\u7ed3\u679c\u3002<\/p>\n<p><a href=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2025\/02\/jt_2025-02-06_11-33-21.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14396\" src=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2025\/02\/jt_2025-02-06_11-33-21.png\" alt=\"\" width=\"1566\" height=\"680\" \/><\/a><\/p>\n<h3>\u8fc7\u6ee4\u8868\u8fbe\u5f0f<\/h3>\n<p>pftop\u8fc7\u6ee4\u5668\u652f\u6301\u5404\u79cd\u8868\u8fbe\u5f0f\u548c\u9009\u9879\uff0c\u53ef\u4ee5\u5bf9\u6d41\u91cf\u8fdb\u884c\u7cbe\u786e\u7b5b\u9009\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u8fc7\u6ee4\u8868\u8fbe\u5f0f\u793a\u4f8b\uff1a<\/p>\n<h4>IP\u5730\u5740\u8fc7\u6ee4<\/h4>\n<ul>\n<li>\u663e\u793a\u6e90 IP \u5730\u5740\u4e3a\u7279\u5b9a\u5730\u5740\u7684\u6d41\u91cf\uff1a\n<div>\n<div dir=\"ltr\">\n<pre class=\"code\">src 192.168.1.100<\/pre>\n<\/div>\n<\/div>\n<\/li>\n<li>\u663e\u793a\u76ee\u6807 IP \u5730\u5740\u4e3a\u7279\u5b9a\u5730\u5740\u7684\u6d41\u91cf\uff1a\n<div>\n<div dir=\"ltr\">\n<pre class=\"code\">dst 192.168.1.100<\/pre>\n<\/div>\n<\/div>\n<\/li>\n<li>\u663e\u793a\u6e90\u6216\u76ee\u6807 IP \u5730\u5740\u4e3a\u7279\u5b9a\u5730\u5740\u7684\u6d41\u91cf\uff1a\n<div>\n<div dir=\"ltr\">\n<pre class=\"code\">host 192.168.1.100<\/pre>\n<\/div>\n<\/div>\n<\/li>\n<li>\u663e\u793a\u6e90 IP \u5730\u5740\u4e3a\u6307\u5b9a\u7f51\u7edc\u7684\u6d41\u91cf\uff1a\n<div>\n<pre class=\"code\">src net 192.168.1.0\/24<\/pre>\n<\/div>\n<\/li>\n<li>\u663e\u793a\u76ee\u6807 IP \u5730\u5740\u4e3a\u6307\u5b9a\u7f51\u7edc\u7684\u6d41\u91cf\uff1a\n<div>\n<pre class=\"code\">dst net 192.168.1.0\/24<\/pre>\n<\/div>\n<\/li>\n<\/ul>\n<h4>\u7aef\u53e3\u8fc7\u6ee4<\/h4>\n<ul>\n<li>\u663e\u793a\u6e90\u7aef\u53e3\u4e3a\u7279\u5b9a\u7aef\u53e3\u7684\u6d41\u91cf\uff1a\n<div>\n<pre class=\"code\">src port 80<\/pre>\n<\/div>\n<\/li>\n<li>\u663e\u793a\u76ee\u6807\u7aef\u53e3\u4e3a\u7279\u5b9a\u7aef\u53e3\u7684\u6d41\u91cf\uff1a\n<div>\n<pre class=\"code\">dst port 80<\/pre>\n<\/div>\n<\/li>\n<li>\u663e\u793a\u6e90\u7aef\u53e3\u6216\u76ee\u6807\u7aef\u53e3\u4e3a\u7279\u5b9a\u7aef\u53e3\u7684\u6d41\u91cf\uff1a\n<div>\n<pre class=\"code\">port 80<\/pre>\n<\/div>\n<\/li>\n<\/ul>\n<h4>\u534f\u8bae\u8fc7\u6ee4<\/h4>\n<ul>\n<li>TCP \u6d41\u91cf\uff1a\n<div>\n<pre class=\"code\">proto tcp<\/pre>\n<\/div>\n<\/li>\n<li>UDP \u6d41\u91cf\uff1a\n<div>\n<pre class=\"code\">proto udp<\/pre>\n<\/div>\n<\/li>\n<li>ICMP \u6d41\u91cf\uff1a\n<div>\n<pre class=\"code\">proto icmp<\/pre>\n<\/div>\n<\/li>\n<\/ul>\n<h4>\u6d41\u91cf\u65b9\u5411\u8fc7\u6ee4<\/h4>\n<ul>\n<li>\u663e\u793a\u4f20\u5165\u6d41\u91cf\uff1a\n<div>\n<pre class=\"code\">in<\/pre>\n<\/div>\n<\/li>\n<li>\u663e\u793a\u4f20\u51fa\u6d41\u91cf\uff1a\n<div>\n<pre class=\"code\">out<\/pre>\n<\/div>\n<\/li>\n<li>\u663e\u793a\u5165\u7ad9\u6d41\u91cf\u6216\u51fa\u7ad9\u6d41\u91cf\uff1a\n<div>\n<pre class=\"code\">in or out<\/pre>\n<\/div>\n<\/li>\n<\/ul>\n<h4>\u6761\u4ef6\u7ec4\u5408<\/h4>\n<ul>\n<li>\u663e\u793a\u6e90 IP \u5730\u5740\u4e3a 192.168.1.100 \u4e14\u76ee\u6807\u7aef\u53e3\u4e3a 80 \u7684TCP\u6d41\u91cf\uff1a\n<div>\n<pre class=\"code\">src 192.168.1.100 and dst port 80 and proto tcp<\/pre>\n<\/div>\n<\/li>\n<li>\u663e\u793a\u4ece\u7f51\u7edc 192.168.1.0\/24 \u5230 10.0.0.0\/24 \u7f51\u7edc\u7684UDP\u6d41\u91cf\uff1a\n<div>\n<pre class=\"code\">src net 192.168.1.0\/24 and dst net 10.0.0.0\/24 and proto udp<\/pre>\n<\/div>\n<\/li>\n<\/ul>\n<h4>\u5176\u4ed6\u5e38\u7528\u8868\u8fbe\u5f0f<\/h4>\n<ul>\n<li>\u663e\u793a\u4e0e 192.168.1.0\/24 \u7f51\u7edc\u76f8\u5173\u7684\u6d41\u91cf\uff08\u4e0d\u8bba\u662f\u6e90\u8fd8\u662f\u76ee\u6807\uff09\uff1a\n<div>\n<pre class=\"code\">net 192.168.1.0\/24<\/pre>\n<\/div>\n<\/li>\n<li>\u663e\u793a\u6d41\u91cf\u4e2d\u5305\u542b\u67d0\u4e2a\u7279\u5b9a\u7aef\u53e3\u7684\u6570\u636e\uff1a\n<div>\n<pre class=\"code\">port 443<\/pre>\n<\/div>\n<\/li>\n<li>\u663e\u793a\u6765\u81ea\u6307\u5b9a IP \u8303\u56f4\u7684\u6d41\u91cf\uff1a\n<div>\n<pre class=\"code\">src net 192.168.0.0\/16<\/pre>\n<\/div>\n<\/li>\n<\/ul>\n<h3>\u6392\u5e8f<\/h3>\n<p>pftop\u53ef\u4ee5\u6839\u636e\u4e0d\u540c\u7684\u6307\u6807\u8fdb\u884c\u6392\u5e8f\uff0c\u4ee5\u65b9\u4fbf\u67e5\u627e\u6240\u9700\u8981\u7684\u6570\u636e\u3002<\/p>\n<p><a href=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2025\/02\/jt_2025-02-06_11-41-08.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-14400 size-full\" src=\"https:\/\/blog.pfchina.org\/wp-content\/uploads\/2025\/02\/jt_2025-02-06_11-41-08.png\" alt=\"\" width=\"1562\" height=\"696\" \/><\/a><\/p>\n<h3>\u6700\u5927\u72b6\u6001\u6570<\/h3>\n<p>\u786e\u5b9a\u6240\u9700\u8981\u67e5\u8be2\u7684\u6570\u91cf\uff0c\u4ece50\u5230\u5168\u90e8\u3002<\/p>\n<h3>\u53c2\u6570\u91ca\u4e49<\/h3>\n<p>Age\uff1a\u65f6\u95f4\u957f\u5ea6\uff0c\u8868\u793a\u8be5\u8fde\u63a5\u5728\u9632\u706b\u5899\u72b6\u6001\u8868\u4e2d\u5df2\u5b58\u5728\u7684\u65f6\u95f4\uff08\u4ece\u8fde\u63a5\u5efa\u7acb\u5230\u5f53\u524d\u65f6\u523b\uff09\u3002<\/p>\n<p>Exp\uff1a\uff08Expiration Time\uff09\u5012\u8ba1\u65f6\u503c\uff0c\u8868\u793a\u8be5\u8fde\u63a5\u5728\u65e0\u6570\u636e\u4ea4\u4e92\u7684\u60c5\u51b5\u4e0b\uff0c\u5269\u4f59\u7684\u5b58\u6d3b\u65f6\u95f4\u3002<\/p>\n<p>pkt\uff1a\u6570\u636e\u5305\uff08packet\uff09\u6570\u91cf\u3002\u5b83\u663e\u793a\u5728\u7ed9\u5b9a\u65f6\u95f4\u5185\uff0c\u5339\u914d\u67d0\u4e2a\u7279\u5b9a\u89c4\u5219\u7684\u5165\u7ad9\u6216\u51fa\u7ad9\u6570\u636e\u5305\u7684\u603b\u6570\u3002<\/p>\n<p>Long\uff1a\u7528\u4e8e\u5207\u6362\u81f3\u8be6\u7ec6\u8f93\u51fa\u6a21\u5f0f\uff0c\u663e\u793a\u66f4\u591a\u5173\u4e8e\u9632\u706b\u5899\u72b6\u6001\u8868\uff08state table\uff09\u4e2d\u6bcf\u4e2a\u8fde\u63a5\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/p>\n<p>Speed\uff1a\u8868\u793a\u5355\u4f4d\u65f6\u95f4\u5185\u901a\u8fc7\u8be5\u8fde\u63a5\u4f20\u8f93\u7684\u6570\u636e\u91cf\uff0c\u53ef\u4ee5\u76d1\u63a7\u901a\u8fc7\u9632\u706b\u5899\u7684\u6bcf\u4e2a\u8fde\u63a5\u5728\u7279\u5b9a\u65f6\u523b\u7684\u5e26\u5bbd\u4f7f\u7528\u60c5\u51b5\u3002<\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u505a\u4e3a\u5e38\u7528\u6545\u969c\u6392\u67e5\u7684\u624b\u6bb5\u4e4b\u4e00\uff0cpftop\u662f\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5b9e\u65f6\u76d1\u63a7\u9632\u706b\u5899\u7684\u7f51\u7edc\u6d41\u91cf\u548c\u8fde\u63a5\u72b6\u6001\uff0c\u719f\u7ec3\u638c\u63e1\u53ef\u4ee5\u5e2e\u52a9\u8fdb\u884c\u6d41\u91cf\u5206\u6790\u6216\u8bca\u65ad\u6027\u80fd\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>pftop\u662f\u4e00\u4e2a\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u7528\u4e8e\u5b9e\u65f6\u76d1\u63a7\u548c\u663e\u793apfSense\u9632\u706b\u5899\u7684\u6d41\u91cf\u548c\u8fde\u63a5\u72b6 &hellip; <a href=\"https:\/\/blog.pfchina.org\/?p=14382\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[468],"class_list":["post-14382","post","type-post","status-publish","format-standard","hentry","category-pfsense","tag-pftop"],"_links":{"self":[{"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=\/wp\/v2\/posts\/14382","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14382"}],"version-history":[{"count":20,"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=\/wp\/v2\/posts\/14382\/revisions"}],"predecessor-version":[{"id":14491,"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=\/wp\/v2\/posts\/14382\/revisions\/14491"}],"wp:attachment":[{"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.pfchina.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}