<script type="application/ld+json">{"@context":"http://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://www.simcentric.com/tc/"},{"@type":"ListItem","position":2,"name":"Ubuntu UFW防火牆配置和優化怎麼做？","item":"https://www.simcentric.com/hong-kong-dedicated-server/how-to-configure-and-optimize-ubuntu-ufw-firewall/"}]}</script> {"id":10971,"date":"2024-02-14T08:45:41","date_gmt":"2024-02-14T00:45:41","guid":{"rendered":"https:\/\/www.simcentric.com\/?p=10971"},"modified":"2024-02-02T12:17:48","modified_gmt":"2024-02-02T04:17:48","slug":"how-to-configure-and-optimize-ubuntu-ufw-firewall","status":"publish","type":"post","link":"https:\/\/www.simcentric.com\/tc\/hong-kong-dedicated-server-tc\/how-to-configure-and-optimize-ubuntu-ufw-firewall\/","title":{"rendered":"Ubuntu UFW\u9632\u706b\u7246\u914d\u7f6e\u548c\u512a\u5316\u600e\u9ebc\u505a\uff1f"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><p>[vc_row el_class=&#8221;blog-detail-section&#8221;][vc_column][vc_column_text]<\/p>\n<p>\u5728\u7576\u4eca\u6578\u78bc\u5316\u6642\u4ee3\uff0c\u7db2\u8def\u5b89\u5168\u5df2\u6210\u70ba\u4f01\u696d\u548c\u500b\u4eba\u7528\u6236\u7684\u9996\u8981\u95dc\u6ce8\u9ede\u4e4b\u4e00\u3002Ubuntu\u4f5c\u70ba\u6700\u53d7\u6b61\u8fce\u7684Linux\u767c\u884c\u7248\u4e4b\u4e00\uff0c\u5176\u5b89\u5168\u6027\u5c24\u5176\u91cd\u8981\u3002UFW\uff08Uncomplicated Firewall\uff09\uff0c\u6216\u7a31\u7c21\u55ae\u9632\u706b\u7246\uff0c\u70baUbuntu\u7528\u6236\u63d0\u4f9b\u4e86\u4e00\u500b\u76f4\u89c0\u4e14\u529f\u80fd\u5f37\u5927\u7684\u5de5\u5177\uff0c\u7528\u65bc\u7ba1\u7406\u5165\u7ad9\u548c\u51fa\u7ad9\u7684\u7db2\u8def\u6d41\u91cf\uff0c\u78ba\u4fdd\u7cfb\u7d71\u7684\u5b89\u5168\u6027\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5011\u5c07\u63a2\u8a0e\u5982\u4f55\u5728Ubuntu\u7cfb\u7d71\u4e2d\u6709\u6548\u914d\u7f6e\u548c\u512a\u5316UFW\uff0c\u4ee5\u4fdd\u969c\u60a8\u7684\u7db2\u8def\u5b89\u5168\u3002<\/p>\n<p>[\/vc_column_text][\/vc_column][\/vc_row][vc_row el_class=&#8221;blog-detail-section&#8221;][vc_column][vc_column_text]<\/p>\n<h2><strong>\u521d\u59cb\u6b65\u9a5f\uff1a\u5b89\u88dd\u8207\u66f4\u65b0<\/strong><\/h2>\n<p>\u5b89\u88ddUFW\u524d\uff0c\u5fc5\u9808\u78ba\u4fdd\u60a8\u7684Ubuntu\u7cfb\u7d71\u662f\u6700\u65b0\u7684\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u66f4\u65b0\u60a8\u7684\u7cfb\u7d71\uff1a<\/p>\n<pre><code>sudo apt-get update &amp;&amp; sudo apt-get upgrade<\/code><\/pre>\n<p>\u5c0d\u65bcDebian\u6216\u57fa\u65bcDebian\u7684\u4f5c\u696d\u7cfb\u7d71\uff0c\u5b89\u88ddUFW\u540c\u6a23\u7c21\u55ae\uff1a<\/p>\n<pre><code>sudo apt-get install ufw<\/code><\/pre>\n<p>\u5728Arch Linux\u4e2d\uff0c\u60a8\u53ef\u4ee5\u901a\u904e\u5982\u4e0b\u547d\u4ee4\u5b89\u88ddUFW\uff1a<\/p>\n<pre><code>sudo pacman -S ufw<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u5c0d\u65bcDebian\u7cfb\u7d71\uff0cUFW\u5c07\u6703\u88ab\u914d\u7f6e\u70ba\u958b\u6a5f\u6642\u81ea\u52d5\u555f\u52d5\u3002Arch Linux\u7528\u6236\u5247\u9700\u8981\u624b\u52d5\u555f\u52d5\u548c\u4f7fUFW\u96a8\u7cfb\u7d71\u555f\u52d5\uff1a<\/p>\n<pre><code>sudo systemctl start ufw\r\nsudo systemctl enable ufw<\/code><\/pre>\n<p>[\/vc_column_text][\/vc_column][\/vc_row][vc_row el_class=&#8221;blog-detail-section&#8221;][vc_column][vc_column_text]<\/p>\n<div class=\"img\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2024\/02\/sim-blog-2024-02-14A2.jpg\" alt=\"\u7db2\u8def\u5b89\u5168\" \/><\/div>\n<p>[\/vc_column_text][\/vc_column][\/vc_row][vc_row el_class=&#8221;blog-detail-section&#8221;][vc_column][vc_column_text]<\/p>\n<h2><strong>\u914d\u7f6eUFW\u898f\u5247<\/strong><\/h2>\n<h3><strong>\u8a2d\u5b9a\u9ed8\u8a8d\u898f\u5247<\/strong><\/h3>\n<p>\u9ed8\u8a8d\u60c5\u6cc1\u4e0b\uff0c\u6700\u4f73\u5be6\u8e10\u662f\u95dc\u9589\u6240\u6709\u672a\u7d93\u8acb\u6c42\u7684\u5165\u7ad9\u9023\u63a5\uff0c\u540c\u6642\u5141\u8a31\u6240\u6709\u51fa\u7ad9\u9023\u63a5\uff1a<\/p>\n<pre><code>sudo ufw default deny incoming\r\nsudo ufw default allow outgoing<\/code><\/pre>\n<h3><strong>\u6dfb\u52a0\u7279\u5b9a\u898f\u5247<\/strong><\/h3>\n<p>UFW\u5141\u8a31\u901a\u904e\u7aef\u53e3\u865f\u6216\u670d\u52d9\u540d\u7a31\u6dfb\u52a0\u898f\u5247\u3002\u4f8b\u5982\uff0c\u70ba\u4e86\u5141\u8a31SSH\u9023\u63a5\uff1a<\/p>\n<pre><code>sudo ufw allow ssh<\/code><\/pre>\n<p>\u6216\u8005\u5141\u8a31\u7279\u5b9a\u7684\u7aef\u53e3\uff1a<\/p>\n<pre><code>sudo ufw allow 22<\/code><\/pre>\n<p>\u5982\u679c\u60a8\u9700\u8981\u91dd\u5c0d\u7279\u5b9a\u7684\u5354\u8b70\u958b\u653e\u7aef\u53e3\uff0c\u53ef\u4ee5\u6307\u5b9aTCP\u6216UDP\uff1a<\/p>\n<pre><code>sudo ufw allow 80\/tcp<\/code><\/pre>\n<h3><strong>\u7ba1\u7406\u898f\u5247<\/strong><\/h3>\n<p>\u70ba\u4e86\u522a\u9664\u6216\u4fee\u6539\u898f\u5247\uff0cUFW\u63d0\u4f9b\u4e86\u7c21\u55ae\u7684\u547d\u4ee4\u3002\u4f8b\u5982\uff0c\u522a\u9664\u5df2\u5b58\u5728\u7684\u898f\u5247\uff1a<\/p>\n<pre><code>sudo ufw delete allow 80<\/code><\/pre>\n<h3><strong>\u555f\u7528\u65e5\u8a8c<\/strong><\/h3>\n<p>\u70ba\u4e86\u76e3\u63a7\u548c\u5be9\u8a08\uff0cUFW\u5141\u8a31\u60a8\u958b\u555f\u65e5\u8a8c\u8a18\u9304\u529f\u80fd\uff1a<\/p>\n<pre><code>sudo ufw logging on<\/code><\/pre>\n<p>\u4e26\u4e14\u60a8\u53ef\u4ee5\u6839\u64da\u9700\u8981\u8a2d\u7f6e\u65e5\u8a8c\u7d1a\u5225\uff1a<\/p>\n<pre><code>sudo ufw logging medium<\/code><\/pre>\n<p>[\/vc_column_text][\/vc_column][\/vc_row][vc_row el_class=&#8221;blog-detail-section&#8221;][vc_column][vc_column_text]<\/p>\n<h2><strong>\u555f\u7528\u548c\u7981\u7528UFW<\/strong><\/h2>\n<p>\u914d\u7f6e\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u555f\u7528UFW\uff1a<\/p>\n<pre><code>sudo ufw enable<\/code><\/pre>\n<p>\u5982\u679c\u9700\u8981\u505c\u6b62UFW\uff0c\u53ef\u4ee5\u4f7f\u7528\uff1a<\/p>\n<pre><code>sudo ufw disable<\/code><\/pre>\n<p>[\/vc_column_text][\/vc_column][\/vc_row][vc_row el_class=&#8221;blog-detail-section&#8221;][vc_column][vc_column_text]<\/p>\n<h2><strong>\u67e5\u770b\u548c\u512a\u5316UFW\u72c0\u614b<\/strong><\/h2>\n<p>\u8981\u67e5\u770bUFW\u7684\u72c0\u614b\u548c\u5df2\u6fc0\u6d3b\u7684\u898f\u5247\uff1a<\/p>\n<pre><code>sudo ufw status<\/code><\/pre>\n<p>[\/vc_column_text][\/vc_column][\/vc_row]<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>[vc_row el_class=&#8221;blog-detail-section&#8221;][vc_ [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"https:\/\/www.simcentric.com\/tc\/hong-kong-dedicated-server-tc\/how-to-configure-and-optimize-ubuntu-ufw-firewall\/\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":10964,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[61],"tags":[1571,578],"class_list":["post-10971","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hong-kong-dedicated-server-tc","tag-ubuntu-ufw-firewall-configuration-tc","tag-network-security-tc"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Ubuntu UFW\u9632\u706b\u7246\u914d\u7f6e\u548c\u512a\u5316\u600e\u9ebc\u505a\uff1f | Simcentric Solutions<\/title>\n<meta name=\"description\" content=\"\u5728\u7576\u4eca\u6578\u78bc\u5316\u6642\u4ee3\uff0c\u7db2\u8def\u5b89\u5168\u5df2\u6210\u70ba\u4f01\u696d\u548c\u500b\u4eba\u7528\u6236\u7684\u9996\u8981\u95dc\u6ce8\u9ede\u4e4b\u4e00\u3002Ubuntu\u4f5c\u70ba\u6700\u53d7\u6b61\u8fce\u7684Linux\u767c\u884c\u7248\u4e4b\u4e00\uff0c\u5176\u5b89\u5168\u6027\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.simcentric.com\/tc\/wp-json\/wp\/v2\/posts\/10971\" \/>\n<meta property=\"og:locale\" content=\"zh_TW\" \/>\n<meta property=\"og:type\" content=\"company\" \/>\n<meta property=\"og:title\" content=\"Ubuntu UFW\u9632\u706b\u7246\u914d\u7f6e\u548c\u512a\u5316\u600e\u9ebc\u505a\uff1f | Simcentric Solutions\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.simcentric.com\/tc\/wp-json\/wp\/v2\/posts\/10971\" \/>\n<meta property=\"og:site_name\" content=\"\u65b0\u5929\u57df\u4e92\u806f\" \/>\n<meta property=\"article:published_time\" content=\"2024-02-14T00:45:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.simcentric.com\/wp-content\/uploads\/2024\/02\/sim-blog-2024-02-14A1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"602\" \/>\n\t<meta property=\"og:image:height\" content=\"520\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Ubuntu UFW\u9632\u706b\u7246\u914d\u7f6e\u548c\u512a\u5316\u600e\u9ebc\u505a\uff1f | Simcentric Solutions","description":"\u5728\u7576\u4eca\u6578\u78bc\u5316\u6642\u4ee3\uff0c\u7db2\u8def\u5b89\u5168\u5df2\u6210\u70ba\u4f01\u696d\u548c\u500b\u4eba\u7528\u6236\u7684\u9996\u8981\u95dc\u6ce8\u9ede\u4e4b\u4e00\u3002Ubuntu\u4f5c\u70ba\u6700\u53d7\u6b61\u8fce\u7684Linux\u767c\u884c\u7248\u4e4b\u4e00\uff0c\u5176\u5b89\u5168\u6027","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.simcentric.com\/tc\/wp-json\/wp\/v2\/posts\/10971","og_locale":"zh_TW","og_type":"company","og_title":"Ubuntu UFW\u9632\u706b\u7246\u914d\u7f6e\u548c\u512a\u5316\u600e\u9ebc\u505a\uff1f | Simcentric Solutions","og_url":"https:\/\/www.simcentric.com\/tc\/wp-json\/wp\/v2\/posts\/10971","og_site_name":"\u65b0\u5929\u57df\u4e92\u806f","article_published_time":"2024-02-14T00:45:41+00:00","og_image":[{"width":602,"height":520,"url":"https:\/\/www.simcentric.com\/wp-content\/uploads\/2024\/02\/sim-blog-2024-02-14A1.jpg","type":"image\/jpeg"}],"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.simcentric.com\/hong-kong-dedicated-server\/how-to-configure-and-optimize-ubuntu-ufw-firewall\/#article","isPartOf":{"@id":"https:\/\/www.simcentric.com\/hong-kong-dedicated-server\/how-to-configure-and-optimize-ubuntu-ufw-firewall\/"},"author":{"name":"Tommy Cheung","@id":"https:\/\/simcentric.com\/tc\/#\/schema\/person\/631e153fdae3d1c71e500611868451e8"},"headline":"Ubuntu UFW\u9632\u706b\u7246\u914d\u7f6e\u548c\u512a\u5316\u600e\u9ebc\u505a\uff1f","datePublished":"2024-02-14T00:45:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.simcentric.com\/hong-kong-dedicated-server\/how-to-configure-and-optimize-ubuntu-ufw-firewall\/"},"wordCount":137,"publisher":{"@id":"https:\/\/simcentric.com\/tc\/#organization"},"image":{"@id":"https:\/\/www.simcentric.com\/hong-kong-dedicated-server\/how-to-configure-and-optimize-ubuntu-ufw-firewall\/#primaryimage"},"thumbnailUrl":"https:\/\/www.simcentric.com\/wp-content\/uploads\/2024\/02\/sim-blog-2024-02-14A1.jpg","keywords":["Ubuntu UFW\u9632\u706b\u7246\u914d\u7f6e","\u7db2\u8def\u5b89\u5168"],"articleSection":["\u9999\u6e2f\u4f3a\u670d\u5668"],"inLanguage":"zh-HK"},{"@type":"WebPage","@id":"https:\/\/www.simcentric.com\/hong-kong-dedicated-server\/how-to-configure-and-optimize-ubuntu-ufw-firewall\/","url":"https:\/\/www.simcentric.com\/hong-kong-dedicated-server\/how-to-configure-and-optimize-ubuntu-ufw-firewall\/","name":"Ubuntu UFW\u9632\u706b\u7246\u914d\u7f6e\u548c\u512a\u5316\u600e\u9ebc\u505a\uff1f | Simcentric Solutions","isPartOf":{"@id":"https:\/\/simcentric.com\/tc\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.simcentric.com\/hong-kong-dedicated-server\/how-to-configure-and-optimize-ubuntu-ufw-firewall\/#primaryimage"},"image":{"@id":"https:\/\/www.simcentric.com\/hong-kong-dedicated-server\/how-to-configure-and-optimize-ubuntu-ufw-firewall\/#primaryimage"},"thumbnailUrl":"https:\/\/www.simcentric.com\/wp-content\/uploads\/2024\/02\/sim-blog-2024-02-14A1.jpg","datePublished":"2024-02-14T00:45:41+00:00","breadcrumb":{"@id":"https:\/\/www.simcentric.com\/hong-kong-dedicated-server\/how-to-configure-and-optimize-ubuntu-ufw-firewall\/#breadcrumb"},"inLanguage":"zh-HK","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.simcentric.com\/hong-kong-dedicated-server\/how-to-configure-and-optimize-ubuntu-ufw-firewall\/"]}]},{"@type":"ImageObject","inLanguage":"zh-HK","@id":"https:\/\/www.simcentric.com\/hong-kong-dedicated-server\/how-to-configure-and-optimize-ubuntu-ufw-firewall\/#primaryimage","url":"https:\/\/www.simcentric.com\/wp-content\/uploads\/2024\/02\/sim-blog-2024-02-14A1.jpg","contentUrl":"https:\/\/www.simcentric.com\/wp-content\/uploads\/2024\/02\/sim-blog-2024-02-14A1.jpg","width":602,"height":520,"caption":"Ubuntu UFW\u9632\u706b\u7246\u914d\u7f6e"},{"@type":"BreadcrumbList","@id":"https:\/\/www.simcentric.com\/hong-kong-dedicated-server\/how-to-configure-and-optimize-ubuntu-ufw-firewall\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.simcentric.com\/tc\/"},{"@type":"ListItem","position":2,"name":"Ubuntu UFW\u9632\u706b\u7246\u914d\u7f6e\u548c\u512a\u5316\u600e\u9ebc\u505a\uff1f"}]},{"@type":"WebSite","@id":"https:\/\/simcentric.com\/tc\/#website","url":"https:\/\/simcentric.com\/tc\/","name":"Simcentric Solutions","description":"","publisher":{"@id":"https:\/\/simcentric.com\/tc\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/simcentric.com\/tc\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-HK"},{"@type":"Organization","@id":"https:\/\/simcentric.com\/tc\/#organization","name":"Simcentric Solutions","url":"https:\/\/simcentric.com\/tc\/","logo":{"@type":"ImageObject","inLanguage":"zh-HK","@id":"https:\/\/simcentric.com\/tc\/#\/schema\/logo\/image\/","url":"https:\/\/www.simcentric.com\/wp-content\/uploads\/2023\/06\/sim-logo-2023.png","contentUrl":"https:\/\/www.simcentric.com\/wp-content\/uploads\/2023\/06\/sim-logo-2023.png","width":800,"height":222,"caption":"Simcentric Solutions"},"image":{"@id":"https:\/\/simcentric.com\/tc\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/simcentric.com\/tc\/#\/schema\/person\/631e153fdae3d1c71e500611868451e8","name":"Tommy Cheung","image":{"@type":"ImageObject","inLanguage":"zh-HK","@id":"https:\/\/secure.gravatar.com\/avatar\/a2e7d94371b76574e2ddc0f18834f815c0329507429c6613f6a7bc9435dc6fd2?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/a2e7d94371b76574e2ddc0f18834f815c0329507429c6613f6a7bc9435dc6fd2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a2e7d94371b76574e2ddc0f18834f815c0329507429c6613f6a7bc9435dc6fd2?s=96&d=mm&r=g","caption":"Tommy Cheung"},"sameAs":["https:\/\/simrevamp2023.sim-dp.com"]}]}},"_links":{"self":[{"href":"https:\/\/www.simcentric.com\/tc\/wp-json\/wp\/v2\/posts\/10971","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.simcentric.com\/tc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.simcentric.com\/tc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.simcentric.com\/tc\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.simcentric.com\/tc\/wp-json\/wp\/v2\/comments?post=10971"}],"version-history":[{"count":2,"href":"https:\/\/www.simcentric.com\/tc\/wp-json\/wp\/v2\/posts\/10971\/revisions"}],"predecessor-version":[{"id":10974,"href":"https:\/\/www.simcentric.com\/tc\/wp-json\/wp\/v2\/posts\/10971\/revisions\/10974"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.simcentric.com\/tc\/wp-json\/wp\/v2\/media\/10964"}],"wp:attachment":[{"href":"https:\/\/www.simcentric.com\/tc\/wp-json\/wp\/v2\/media?parent=10971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.simcentric.com\/tc\/wp-json\/wp\/v2\/categories?post=10971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.simcentric.com\/tc\/wp-json\/wp\/v2\/tags?post=10971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}