{"id":34,"date":"2011-06-03T13:21:40","date_gmt":"2011-06-03T05:21:40","guid":{"rendered":"http:\/\/www.kiccleaf.com\/?p=34"},"modified":"2020-08-27T15:42:42","modified_gmt":"2020-08-27T07:42:42","slug":"%e9%98%b2%e7%81%ab%e5%a2%99%e6%97%a5%e5%b8%b8%e6%93%8d%e4%bd%9c%e8%ae%b0%e5%bd%95","status":"publish","type":"post","link":"http:\/\/www.kiccleaf.com\/?p=34","title":{"rendered":"\u9632\u706b\u5899\u65e5\u5e38\u64cd\u4f5c\u8bb0\u5f55"},"content":{"rendered":"<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&#x5B;root@kiccleaf home]# iptables -F \u6e05\u9664\u9884\u8bbe\u8868filter \u4e2d\u7684\u6240\u6709\u89c4\u5219\u94fe\u7684\u89c4\u5219\r\n&#x5B;root@kiccleaf home]# iptables -X \u6e05\u9664\u9884\u8bbe\u8868filter \u4e2d\u4f7f\u7528\u8005\u81ea\u5b9a\u94fe\u4e2d\u7684\u89c4\u5219\r\n&#x5B;root@kiccleaf home]# \/etc\/rc.d\/init.d\/iptables save \u4fdd\u5b58\u5f53\u524d\u64cd\u4f5c\r\n\u5c06\u5f53\u524d\u89c4\u5219\u4fdd\u5b58\u5230 \/etc\/sysconfig\/iptables\uff1a &#x5B;\u786e\u5b9a]\r\n&#x5B;root@kiccleaf home]# service iptables restart \u91cd\u542f\u9632\u706b\u5899\r\n\u6e05\u9664\u9632\u706b\u5899\u89c4\u5219\uff1a &#x5B;\u786e\u5b9a]\r\n\u628a chains \u8bbe\u7f6e\u4e3a ACCEPT \u7b56\u7565\uff1afilter &#x5B;\u786e\u5b9a]\r\n\u6b63\u5728\u5378\u8f7d Iiptables \u6a21\u5757\uff1a &#x5B;\u786e\u5b9a]\r\n\u5e94\u7528 iptables \u9632\u706b\u5899\u89c4\u5219\uff1a &#x5B;\u786e\u5b9a]\r\n\u8f7d\u5165\u989d\u5916 iptables \u6a21\u5757\uff1aip_conntrack_netbios_ns &#x5B;\u786e\u5b9a]\r\n&#x5B;root@kiccleaf home]# iptables -L -n \u67e5\u770b\u9632\u706b\u5899\u89c4\u5219\uff08\u5df2\u7ecf\u5168\u90e8\u6e05\u9664\uff09\r\nChain INPUT (policy ACCEPT)\r\ntarget prot opt source destination\r\nChain FORWARD (policy ACCEPT)\r\ntarget prot opt source destination\r\nChain OUTPUT (policy ACCEPT)\r\ntarget prot opt source destination\r\n\u8fdc\u7a0bSSH \u767b\u9646,\u6211\u4eec\u8981\u5f00\u542f22 \u7aef\u53e3\r\n&#x5B;root@kiccleaf home]# iptables -A INPUT -p tcp --dport 22 -j ACCEPT\r\n&#x5B;root@kiccleaf home]# iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT\r\n\u5982\u679c\u505a\u4e86WEB \u670d\u52a1\u5668,\u5f00\u542f80 \u7aef\u53e3\r\n&#x5B;root@kiccleaf home]# iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT\r\n&#x5B;root@kiccleaf home]# iptables -A INPUT -p tcp --dport 80 -j ACCEPT\r\n\u5982\u679c\u505a\u4e86FTP \u670d\u52a1\u5668,\u5f00\u542f21 \u7aef\u53e3\r\n&#x5B;root@kiccleaf home]# iptables -A INPUT -p tcp --dport 21 -j ACCEPT\r\n&#x5B;root@kiccleaf home]# iptables -A INPUT -p tcp --dport 20 -j ACCEPT\r\n\u5141\u8bb8icmp \u5305\u901a\u8fc7,\u4e5f\u5c31\u662f\u5141\u8bb8ping\r\n&#x5B;root@kiccleaf home]# iptables -A OUTPUT -p icmp -j ACCEPT\r\n&#x5B;root@kiccleaf home]# iptables -A INPUT -p icmp -j ACCEPT\r\n\u5141\u8bb8loopback!(\u4e0d\u7136\u4f1a\u5bfc\u81f4DNS \u65e0\u6cd5\u6b63\u5e38\u5173\u95ed\u7b49\u95ee\u9898)\r\n&#x5B;root@kiccleaf home]# iptables -A INPUT -i lo -p all -j ACCEPT\r\n&#x5B;root@kiccleaf home]# iptables -A OUTPUT -o lo -p all -j ACCEPT\r\n\u51cf\u5c11\u4e0d\u5b89\u5168\u7684\u7aef\u53e3\u8fde\u63a5\r\n&#x5B;root@kiccleaf home]# iptables -A OUTPUT -p tcp --sport 31337 -j DROP\r\n&#x5B;root@kiccleaf home]# iptables -A OUTPUT -p tcp --dport 31337 -j DROP\r\ndrop \u975e\u6cd5\u8fde\u63a5\r\n&#x5B;root@kiccleaf home]# iptables -A INPUT -m state --state INVALID -j DROP\r\n&#x5B;root@kiccleaf home]# iptables -A OUTPUT -m state --state INVALID -j DROP\r\n&#x5B;root@kiccleaf home]# iptables -A FORWARD -m state --state INVALID -j DROP\r\n\u5141\u8bb8\u6240\u6709\u5df2\u7ecf\u5efa\u7acb\u7684\u548c\u76f8\u5173\u7684\u8fde\u63a5\r\n&#x5B;root@kiccleaf home]# iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT\r\n&#x5B;root@kiccleaf home]# iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT\r\n&#x5B;root@kiccleaf home]# \/etc\/rc.d\/init.d\/iptables save\r\n\u5c06\u5f53\u524d\u89c4\u5219\u4fdd\u5b58\u5230 \/etc\/sysconfig\/iptables\uff1a &#x5B;\u786e\u5b9a]\r\n&#x5B;root@kiccleaf home]# service iptables restart\r\n\u6e05\u9664\u9632\u706b\u5899\u89c4\u5219\uff1a &#x5B;\u786e\u5b9a]\r\n\u628a chains \u8bbe\u7f6e\u4e3a ACCEPT \u7b56\u7565\uff1afilter &#x5B;\u786e\u5b9a]\r\n\u6b63\u5728\u5378\u8f7d Iiptables \u6a21\u5757\uff1a &#x5B;\u786e\u5b9a]\r\n\u5e94\u7528 iptables \u9632\u706b\u5899\u89c4\u5219\uff1a &#x5B;\u786e\u5b9a]\r\n\u8f7d\u5165\u989d\u5916 iptables \u6a21\u5757\uff1aip_conntrack_netbios_ns &#x5B;\u786e\u5b9a]\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#x5B;root@kiccleaf home]&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"http:\/\/www.kiccleaf.com\/?p=34\">Continue reading<span class=\"screen-reader-text\">\u9632\u706b\u5899\u65e5\u5e38\u64cd\u4f5c\u8bb0\u5f55<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":2,"footnotes":""},"categories":[4],"tags":[11,12],"class_list":["post-34","post","type-post","status-publish","format-standard","hentry","category-linux-","tag-iptables","tag-12","entry"],"views":3407,"_links":{"self":[{"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=\/wp\/v2\/posts\/34","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=34"}],"version-history":[{"count":1,"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=\/wp\/v2\/posts\/34\/revisions"}],"predecessor-version":[{"id":689,"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=\/wp\/v2\/posts\/34\/revisions\/689"}],"wp:attachment":[{"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=34"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=34"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=34"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}