{"id":292946,"date":"2024-09-13T12:09:08","date_gmt":"2024-09-13T04:09:08","guid":{"rendered":"https:\/\/lrxjmw.cn\/xjrhzfwqsazp.html"},"modified":"2024-09-13T12:09:08","modified_gmt":"2024-09-13T04:09:08","slug":"xjrhzfwqsazp","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/xjrhzfwqsazp.html","title":{"rendered":"\u8be6\u89e3\u5982\u4f55\u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5\u3001\u914d\u7f6e\u548c\u7ba1\u7406 iptables \u9632\u706b\u5899"},"content":{"rendered":"

\u4f7f\u7528iptables\u914d\u7f6e\u9632\u706b\u5899\u89c4\u5219<\/p>\n

\u9632\u706b\u5899\u662f\u4fdd\u969c\u670d\u52a1\u5668\u5b89\u5168\u7684\u91cd\u8981\u4e00\u73af\uff0ciptables\u4f5c\u4e3aLinux<\/a>\u7cfb\u7edf\u4e2d\u5e38\u7528\u7684\u9632\u706b\u5899\u5de5\u5177\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u63a7\u5236\u7f51\u8def\u6d41\u91cf\u3002\u672c\u6587\u5c06\u8be6\u5c3d\u4ecb\u7ecd\u600e\u6837\u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5\u3001\u914d\u7f6e\u548c\u7ba1\u7406iptables\uff0c\u4ee5\u53ca\u4e00\u4e9b\u6ce8\u610f\u4e8b\u9879\u3002<\/p>\n

\u9632\u706b\u5899\u914d\u7f6e\u547d\u4ee4_\u9632\u706b\u5899\u914d\u7f6e\u5b9e\u4f8b_linux\u9632\u706b\u5899 \u914d\u7f6e<\/p>\n

\u4e00\u3001\u68c0\u67e5iptables\u72b6\u6001<\/p>\n

\u5728\u5f00\u59cb\u914d\u7f6eiptables\u4e4b\u524d\uff0c\u9996\u5148\u8981\u786e\u4fddiptables\u670d\u52a1\u662f\u5426\u5df2\u542f\u52a8\u5e76\u68c0\u6d4b\u5f53\u524d\u7684\u89c4\u5219\u3002<\/p>\n

\u67e5\u770biptables\u670d\u52a1\u72b6\u6001\uff1a<\/p>\n

\n

systemctl<\/span> status iptables<\/span><\/code><\/pre>\n<\/p>\n

\u6b64\u547d\u4ee4<\/a>\u4f1a\u663e\u793aiptables\u670d\u52a1\u662f\u5426\u6b63\u5728\u8fd0\u884c\u3002<\/p>\n

\u67e5\u770b\u5f53\u524diptables\u89c4\u5219\uff1a<\/p>\n

\n

iptables<\/span> -nL<\/span><\/code><\/pre>\n<\/p>\n

linux\u9632\u706b\u5899 \u914d\u7f6e_\u9632\u706b\u5899\u914d\u7f6e\u547d\u4ee4_\u9632\u706b\u5899\u914d\u7f6e\u5b9e\u4f8b<\/p>\n

\u6b64\u547d\u4ee4\u5217\u4e3e\u5f53\u524d\u751f\u6548\u7684iptables\u89c4\u5219\u3002\u82e5\u672a\u5b89\u88c5iptables\u6216\u65e0\u914d\u7f6e\u89c4\u5219\uff0c\u53ef\u80fd\u4e0d\u4f1a\u663e\u793a\u4efb\u4f55\u5185\u5bb9\u3002<\/p>\n

\u4e8c\u3001\u5b89\u88c5iptables<\/p>\n

\u5047\u5982\u670d\u52a1\u5668\u4e0a\u672a\u5b89\u88c5iptables\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n

\u4e0b\u8f7diptables\u5b89\u88c5\u5305\uff1a<\/p>\n

\u901a\u8fc7wget\u547d\u4ee4\u4e0b\u8f7d\u6240\u9700\u7684\u5b89\u88c5\u5305\uff1a<\/p>\n

\n

wget https:<\/span>\/\/alist.ywsj.cf\/d<\/span>\/share\/linux<\/span>\/iptables\/iptables<\/span>-1.4<\/span>.21<\/span>-35<\/span>.el7.x86_64.rpm?sign=-S73URRtjJURlFK5Dr6lEPZwOB_UfhPaKjFM5N7ZuTY=:<\/span>0<\/span><\/span><\/code><\/pre>\n<\/p>\n

\n

wget https:<\/span>\/\/alist.ywsj.cf\/d<\/span>\/share\/linux<\/span>\/iptables\/iptables<\/span>-services-1.4<\/span>.21<\/span>-35<\/span>.el7.x86_64.rpm?sign=q2RhRTCZsSeQJalmqksNyeDJ6rH4WulDHzBXERAsB6Y=:<\/span>0<\/span><\/span><\/code><\/pre>\n<\/p>\n

\u5b89\u88c5iptables\uff1a<\/p>\n

\u4f7f\u7528rpm\u547d\u4ee4\u5b89\u88c5\u4e0b\u8f7d\u7684\u5305\uff1a<\/p>\n

\n

rpm<\/span> -Uvh<\/span> iptables-1<\/span>.4<\/span>.21-35<\/span>.el7<\/span>.x86_64<\/span>.rpm<\/span><\/span><\/code><\/pre>\n<\/p>\n

\n

rpm<\/span> -Uvh<\/span> iptables-services-1<\/span>.4<\/span>.21-35<\/span>.el7<\/span>.x86_64<\/span>.rpm<\/span><\/span><\/code><\/pre>\n<\/p>\n

\u5907\u4efd\u9ed8\u8ba4\u914d\u7f6e\uff1a<\/p>\n

\n

cp<\/span> \/etc\/sysconfig\/iptables \/etc\/sysconfig\/iptables_bak<\/span><\/code><\/pre>\n<\/p>\n

\u4e3a\u4e86\u907f\u514d\u8bef\u64cd\u4f5clinux\u9632\u706b\u5899 \u914d\u7f6e<\/strong>linux\u8fd0\u7ef4\u6700\u4f73\u5b9e\u8df5\uff0c\u5efa\u8bae\u5907\u4efd\u9ed8\u8ba4\u7684iptables\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n

\u4e09\u3001\u914d\u7f6eiptables\u89c4\u5219<\/p>\n

\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f9d\u7167\u9700\u6c42\u7f16\u8f91iptables\u89c4\u5219\u6587\u4ef6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u914d\u7f6e\uff1a<\/p>\n

\u7f16\u8f91iptables\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n

\n

vim<\/span> \/etc\/sysconfig\/iptables<\/span><\/code><\/pre>\n<\/p>\n

\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n

\n

# sample<\/span> configuration<\/span> for<\/span> iptables<\/span> service<\/span><\/span><\/code># you<\/span> can<\/span> edit<\/span> this<\/span> manually<\/span> or<\/span> use<\/span> system-config-firewall<\/span><\/span><\/code># please<\/span> do<\/span> not<\/span> ask<\/span> us<\/span> to<\/span> add<\/span> additional<\/span> ports<\/span>\/services<\/span> to<\/span> this<\/span> default<\/span> configuration<\/span><\/span><\/code>*filter<\/span><\/span><\/code>:INPUT<\/span> ACCEPT<\/span> [0:0]<\/span><\/span><\/code>:FORWARD<\/span> ACCEPT<\/span> [0:0]<\/span><\/span><\/code>:OUTPUT<\/span> ACCEPT<\/span> [0:0]<\/span><\/span><\/code>
<\/span><\/code>
<\/span><\/code>-A<\/span> INPUT<\/span> -m<\/span> state<\/span> --state<\/span> RELATED<\/span>,ESTABLISHED<\/span> -j<\/span> ACCEPT<\/span><\/span><\/code>-A<\/span> INPUT<\/span> -p<\/span> icmp<\/span> -j<\/span> ACCEPT<\/span><\/span><\/code>-A<\/span> INPUT<\/span> -i<\/span> lo<\/span> -j<\/span> ACCEPT<\/span><\/span><\/code>-A<\/span> INPUT<\/span> -p<\/span> tcp<\/span> -m<\/span> state<\/span> --state<\/span> NEW<\/span> -m<\/span> tcp<\/span> --dport<\/span> 22 -j<\/span> ACCEPT<\/span><\/span><\/code>-A<\/span> INPUT<\/span> -s<\/span> 127.0<\/span>.0<\/span>.1<\/span> -d<\/span> 127.0<\/span>.0<\/span>.1<\/span> -j<\/span> ACCEPT<\/span><\/span><\/code>
<\/span><\/code>
<\/span><\/code># \u6dfb\u52a0\u767d\u540d\u5355IP<\/span><\/span><\/code>-A<\/span> INPUT<\/span> -s<\/span> 35.241<\/span>.119<\/span>.219<\/span> -j<\/span> ACCEPT<\/span><\/span><\/code>-A<\/span> INPUT<\/span> -s<\/span> 192.168<\/span>.131<\/span>.194<\/span> -j<\/span> ACCEPT<\/span><\/span><\/code>#...\u7ee7\u7eed\u6dfb\u52a0\u767d\u540d\u5355IP<\/span>...<\/span><\/code>
<\/span><\/code>
<\/span><\/code># \u62d2\u7edd\u975e\u767d\u540d\u5355IP<\/span>\u8bbf\u95ee9999\u7aef\u53e3<\/span><\/code>-A<\/span> INPUT<\/span> -p<\/span> tcp<\/span> --dport<\/span> 9999 -j<\/span> DROP<\/span><\/span><\/code>
<\/span><\/code>
<\/span><\/code>COMMIT<\/span><\/span><\/code><\/pre>\n<\/p>\n

\u8be5\u914d\u7f6e\u6587\u4ef6\u5c06\u5bb9\u8bb8\u672c\u5730\u56de\u73af\u3001SSH\u8054\u63a5\u3001\u767d\u540d\u5355IP\u7684\u8bbf\u95ee\uff0c\u5e76\u62d2\u7edd\u5176\u4ed6IP\u5bf9\u6307\u5b9a\u7aef\u53e3\u7684\u8bbf\u95ee\u3002<\/p>\n

\u56db\u3001\u91cd\u542fiptables\u670d\u52a1<\/p>\n

\u5728\u914d\u7f6e\u5b8c\u89c4\u5219\u540e\uff0c\u987b\u8981\u91cd\u542fiptables\u4f7f\u5176\u751f\u6548\u3002<\/p>\n

\u91cd\u65b0\u52a0\u8f7diptables\u89c4\u5219\uff08\u4e0d\u5f71\u54cd\u73b0\u6709\u8054\u63a5\uff09\uff1a<\/p>\n

\n

systemctl<\/span> reload iptables<\/span><\/code><\/pre>\n<\/p>\n

\u91cd\u542fiptables\u670d\u52a1\uff08\u53ef\u80fd\u9020\u6210\u77ed\u6682\u4e2d\u65ad\uff09\uff1a<\/p>\n

\n

systemctl<\/span> restart iptables<\/span><\/code><\/pre>\n<\/p>\n

linux\u9632\u706b\u5899 \u914d\u7f6e_\u9632\u706b\u5899\u914d\u7f6e\u5b9e\u4f8b_\u9632\u706b\u5899\u914d\u7f6e\u547d\u4ee4<\/p>\n

\u518d\u5ea6\u67e5\u770b\u89c4\u5219\uff1a<\/p>\n

\n

iptables<\/span> -nL<\/span><\/code><\/pre>\n<\/p>\n

\u4ee5\u786e\u8ba4\u65b0\u653f\u5219\u5df2\u6210\u529f\u5e94\u7528\u3002<\/p>\n

\u4e94\u3001\u7ba1\u7406iptables\u89c4\u5219<\/p>\n

\u82e5\u9700\u5220\u6389\u6216\u8c03\u6574\u89c4\u5219\uff0c\u53ef\u4ee5\u518d\u5ea6\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\u5e76\u91cd\u542f\u670d\u52a1\u3002<\/p>\n

\u7f16\u8f91iptables\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n

\n

vim<\/span> \/etc\/sysconfig\/iptables<\/span><\/code><\/pre>\n<\/p>\n

\u91cd\u542fiptables\uff1a<\/p>\n

\n

systemctl<\/span> restart iptables<\/span><\/code><\/pre>\n<\/p>\n

\u9632\u706b\u5899\u914d\u7f6e\u547d\u4ee4_linux\u9632\u706b\u5899 \u914d\u7f6e_\u9632\u706b\u5899\u914d\u7f6e\u5b9e\u4f8b<\/p>\n

\u516d\u3001\u6e05\u7a7aiptables\u89c4\u5219\u8868\uff08\u614e\u91cd\u64cd\u4f5c\uff09<\/p>\n

\u6709\u65f6\u987b\u8981\u6e05\u7a7a\u6240\u6709iptables\u89c4\u5219\uff0c\u4ee5\u4e0b\u662f\u6e05\u7a7a\u547d\u4ee4\uff1a<\/p>\n

\u6e05\u7a7a\u6240\u6709\u89c4\u5219\uff1a<\/p>\n

\n

sudo<\/span> iptables -F<\/span><\/code><\/pre>\n<\/p>\n

\u6216\u5219\uff1a<\/p>\n

\n

sudo<\/span> iptables --flush<\/span><\/code><\/pre>\n<\/p>\n

\u6ce8\u610f\uff1a\u5728\u6e05\u7a7a\u89c4\u5219\u4e4b\u524d\uff0c\u786e\u4fdd\u4e0d\u4f1a\u8bef\u5220\u6389SSH\u8054\u63a5\u89c4\u5219linux\u9632\u706b\u5899 \u914d\u7f6e<\/strong>\uff0c\u5426\u5219\u53ef\u80fd\u4f1a\u9020\u6210\u96be\u4ee5\u8fdc\u7a0b\u8054\u63a5\u670d\u52a1\u5668\u3002<\/p>\n

\u603b\u7ed3<\/p>\n

\u901a\u8fc7\u914d\u7f6eiptables\uff0c\u4f60\u53ef\u4ee5\u6709\u6548\u5730\u63a7\u5236\u670d\u52a1\u5668\u7684\u7f51\u8def\u8bbf\u95ee\uff0c\u4fdd\u969c\u7cfb\u7edf\u5b89\u5168\u3002\u5728\u64cd\u4f5c\u65f6\u8981\u5206\u5916\u7559\u795e\uff0c\u5c24\u5176\u662f\u6d89\u53caSSH\u8054\u63a5\u7684\u89c4\u5219\u914d\u7f6elinux\u67e5\u770b\u78c1\u76d8\u7a7a\u95f4\uff0c\u9632\u6b62\u56e0\u914d\u7f6e\u9519\u8bef\u800c\u9020\u6210\u8054\u63a5\u4e2d\u65ad\u3002\u5e0c\u671b\u672c\u6587\u80fd\u5e2e\u52a9\u4f60\u719f\u7ec3\u628a\u63e1iptables\u7684\u4f7f\u7528\u65b9\u5f0f\uff0c\u63d0\u9ad8\u670d\u52a1\u5668\u7684\u5b89\u5168\u6027\u3002<\/p>\n

\u9632\u706b\u5899\u914d\u7f6e\u5b9e\u4f8b_linux\u9632\u706b\u5899 \u914d\u7f6e_\u9632\u706b\u5899\u914d\u7f6e\u547d\u4ee4<\/p>\n

\u9632\u706b\u5899\u914d\u7f6e\u5b9e\u4f8b_linux\u9632\u706b\u5899 \u914d\u7f6e_\u9632\u706b\u5899\u914d\u7f6e\u547d\u4ee4<\/p>\n","protected":false},"excerpt":{"rendered":"

\u4f7f\u7528iptables\u914d\u7f6e\u9632\u706b\u5899\u89c4\u5219\u82e5\u672a\u5b89\u88c5iptables\u6216\u65e0\u914d\u7f6e\u89c4\u5219\uff0c\u53ef\u80fd\u4e0d\u4f1a\u663e\u793a\u4efb\u4f55\u5185\u5bb9\u3002\u5907\u4efd\u9ed8\u8ba4\u914d\u7f6e\uff1a\u4e3a\u4e86\u9632\u6b62\u8bef\u64cd\u4f5c\uff0c\u5efa\u8bae\u5907\u4efd\u9ed8\u8ba4\u7684iptables\u914d\u7f6e\u6587\u4ef6\u3002\u4e09\u3001\u914d\u7f6eiptables\u89c4\u5219\u901a\u8fc7\u914d\u7f6eiptables\uff0c\u4f60\u53ef\u4ee5\u6709\u6548\u5730\u63a7\u5236\u670d\u52a1\u5668\u7684\u7f51\u7edc\u8bbf\u95ee\uff0c\u4fdd\u969c\u7cfb\u7edf\u5b89\u5168\u3002<\/p>\n","protected":false},"author":1,"featured_media":292947,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[1668,2969,2970,2968,1426],"class_list":["post-292946","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-i-15","tag-slpz","tag-bj-5","tag-gzwj","tag-fhq"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/292946","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=292946"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/292946\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/292947"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=292946"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=292946"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=292946"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}