{"id":54,"date":"2016-12-30T00:47:34","date_gmt":"2016-12-29T16:47:34","guid":{"rendered":"https:\/\/wp.yaanren.xin\/?p=20"},"modified":"2016-12-30T00:47:34","modified_gmt":"2016-12-29T16:47:34","slug":"centos7%e4%b8%8b%e5%90%af%e7%94%a8%e7%ab%af%e5%8f%a3","status":"publish","type":"post","link":"https:\/\/wp.625300.xyz\/?p=54","title":{"rendered":"Centos7\u4e0b\u542f\u7528\u7aef\u53e3"},"content":{"rendered":"<div class=\"article_title\">\u8f6c\u8f7d\u81ea\uff1a http:\/\/blog.csdn.net\/zp1996323\/article\/details\/52336851<\/div>\n<div><\/div>\n<div id=\"article_content\" class=\"article_content\">\n<div class=\"markdown_views\">\n<p>\u4eca\u5929\u5199\u4e86\u4e00\u4e0b<code>node<\/code>\u7684\u5c0fdemo\uff0c\u4e8e\u662f\u60f3\u653e\u5230\u963f\u91cc\u4e91\u670d\u52a1\u5668\u4e0a\uff0c\u4f46\u662f\u8bbf\u95ee\u65f6\u5374\u53d1\u751f\u4e86\u9519\u8bef\u3002\u8003\u8651\u4e86\u4e0b\uff0c\u89c9\u5f97\u95ee\u9898\u5728\u4e8e\u7aef\u53e3\u53f7\u4e0a\uff0c\u6211\u5199\u7684<code>node<\/code>demo\u662f\u76d1\u542c\u7684<code>3000<\/code>\u7aef\u53e3\uff0c\u7136\u800c<code><a class=\"replace_word\" title=\"Linux\u77e5\u8bc6\u5e93\" href=\"http:\/\/lib.csdn.net\/base\/linux\" target=\"_blank\" rel=\"noopener\">Linux<\/a><\/code>\u4e0b\u6709\u9632\u706b\u5899\u9ed8\u8ba4\u53ea\u6709<code>80<\/code>\u7aef\u53e3\u5f00\u653e\uff0c\u4e8e\u662f\u5c1d\u8bd5\u4e86\u4e0b\u5c06\u670d\u52a1\u5668\u7684<code>3000<\/code>\u7aef\u53e3\u6253\u5f00\uff0c\u671f\u95f4\u8fd8\u662f\u9047\u5751\u4e0d\u5c11\uff0c\u4e0b\u9762\u5c31\u68b3\u7406\u4e0b\u6574\u4e2a\u8fc7\u7a0b\uff1a<\/p>\n<h2 id=\"\u5173\u95ed\u9632\u706b\u5899\"><a name=\"t0\"><\/a>\u5173\u95ed\u9632\u706b\u5899<\/h2>\n<p>\u7f51\u4e0a\u7684\u5927\u90e8\u5206\u8d44\u6599\u90fd\u662f\u7528<code>iptables<\/code>\u9632\u706b\u5899\u7684\uff0c\u4f46\u662f\u963f\u91cc\u4e91\u7684<code>centos 7<\/code>\u9ed8\u8ba4\u9632\u706b\u5899\u662f<code>firewall<\/code>\u3002\u6700\u4e3a\u7b80\u5355\u7684\u65b9\u6cd5\u5176\u5b9e\u5c31\u662f\u5173\u95ed\u6211\u4eec\u7684\u9632\u706b\u5899\uff1a<\/p>\n<ul>\n<li>\u67e5\u770b\u4e0b\u9632\u706b\u5899\u7684\u72b6\u6001\uff1a<\/li>\n<\/ul>\n<pre class=\"prettyprint\"><code class=\"hljs has-numbering\">systemctl status firewalld<\/code><\/pre>\n<p><img decoding=\"async\" title=\"\" src=\"http:\/\/img.blog.csdn.net\/20160827152417097\" alt=\"\u8fd9\u91cc\u5199\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u5173\u95ed\u9632\u706b\u5899\uff1a<\/li>\n<\/ul>\n<pre class=\"prettyprint\"><code class=\"hljs vbnet has-numbering\">systemctl <span class=\"hljs-keyword\">stop<\/span> firewalld<\/code><\/pre>\n<p>\u8fd9\u6837\u5c31\u89e3\u51b3\u4e86\uff0c\u5728\u8bbf\u95ee\u4e0b<code>ip\u5730\u5740:\u7aef\u53e3\u53f7<\/code>\u5c31\u53ef\u4ee5\u770b\u5230\u6240\u5199\u7684\u5e94\u7528\u5566\uff01<br \/>\n\u4f46\u662f\u8fd9\u6837\u7684\u95ee\u9898\u662f\u5f88\u4e0d\u5b89\u5168\uff0c\u5176\u5b9e\u53ef\u4ee5\u5c06<code>firewall<\/code>\u670d\u52a1\u7981\u7528\uff0c\u5e94\u7528<code>iptables<\/code>\u670d\u52a1\uff08\u7f51\u4e0a\u5927\u90e8\u5206\u542f\u7528\u7aef\u53e3\u7684\u8d44\u6599\u90fd\u662f\u57fa\u4e8e<code>iptables<\/code>\u670d\u52a1\uff09\u3002<\/p>\n<h2 id=\"\u5b89\u88c5iptables\"><a name=\"t1\"><\/a>\u5b89\u88c5iptables<\/h2>\n<p>\u7531\u4e8e\u6ca1\u6709\u9632\u706b\u5899\u4f1a\u9020\u6210\u4e0d\u5b89\u5168\uff0c\u6240\u4ee5\u7ed9\u670d\u52a1\u5668\u5b89\u88c5\u4e00\u5e94\u7528\u66f4\u5e7f\u7684\u9632\u706b\u5899<code>iptables<\/code>\uff0c\u9996\u5148\u8981\u7981\u7528<code>firewall<\/code>\uff0c\u901a\u8fc7<code>yum<\/code>\u5b89\u88c5<code>iptables<\/code>\uff1a<\/p>\n<pre class=\"prettyprint\"><code class=\"hljs lasso has-numbering\">systemctil disable firewalld\nyum install <span class=\"hljs-attribute\">-y<\/span> iptables<span class=\"hljs-attribute\">-services<\/span><\/code><\/pre>\n<h2 id=\"\u542f\u52a8iptables\"><a name=\"t2\"><\/a>\u542f\u52a8iptables<\/h2>\n<pre class=\"prettyprint\"><code class=\"hljs sql has-numbering\">systemctl <span class=\"hljs-operator\"><span class=\"hljs-keyword\">start<\/span> iptables<\/span><\/code><\/pre>\n<p>\u542f\u52a8\u540e\u53ef\u4ee5\u901a\u8fc7<code>systemctl status iptables<\/code>\u67e5\u770b\u72b6\u6001\u3002<\/p>\n<h2 id=\"\u66f4\u6539iptables\u89c4\u5219\"><a name=\"t3\"><\/a>\u66f4\u6539iptables\u89c4\u5219<\/h2>\n<ul>\n<li>\u5c06<code>iptables<\/code>\u6587\u4ef6\u5907\u4efd\u4e0b\uff1a<\/li>\n<\/ul>\n<pre class=\"prettyprint\"><code class=\"hljs avrasm has-numbering\"><span class=\"hljs-keyword\">cp<\/span> -a \/etc\/sysconfig\/iptables \/etc\/sysconfig\/iptables<span class=\"hljs-preprocessor\">.bak<\/span><\/code><\/pre>\n<ul>\n<li>\u8bbe\u7f6e INPUT \u65b9\u5411\u6240\u6709\u7684\u8bf7\u6c42\u90fd\u62d2\u7edd<\/li>\n<\/ul>\n<pre class=\"prettyprint\"><code class=\"hljs sql has-numbering\">iptables -P INPUT <span class=\"hljs-operator\"><span class=\"hljs-keyword\">DROP<\/span><\/span><\/code><\/pre>\n<ul>\n<li>\u653e\u5f00\u6240\u9700\u7aef\u53e3<\/li>\n<\/ul>\n<pre class=\"prettyprint\"><code class=\"hljs lasso has-numbering\">iptables <span class=\"hljs-attribute\">-I<\/span> INPUT <span class=\"hljs-attribute\">-p<\/span> tcp <span class=\"hljs-subst\">--<\/span>dport <span class=\"hljs-number\">80<\/span> <span class=\"hljs-attribute\">-m<\/span> state <span class=\"hljs-subst\">--<\/span>state <span class=\"hljs-literal\">NEW<\/span> <span class=\"hljs-attribute\">-j<\/span> ACCEPT\niptables <span class=\"hljs-attribute\">-I<\/span> INPUT <span class=\"hljs-attribute\">-p<\/span> tcp <span class=\"hljs-subst\">--<\/span>dport <span class=\"hljs-number\">3000<\/span> <span class=\"hljs-attribute\">-m<\/span> state <span class=\"hljs-subst\">--<\/span>state <span class=\"hljs-literal\">NEW<\/span> <span class=\"hljs-attribute\">-j<\/span> ACCEPT<\/code><\/pre>\n<ul class=\"pre-numbering\">\n<li>\u5728\u8fd9\u91cc\u6211\u4eec\u8fd8\u9700\u8981\u6253\u5f00iptables\u7684\u9632\u706b\u5899:\u4e3e\u4e2a\u6817\u5b50\uff0c\u901a\u8fc7\u4e0b\u9762\u7684\u4ee3\u7801\u53ef\u4ee5\u6253\u5f0010000\u523020000\u4e4b\u95f4\u7684\u6240\u6709\u7aef\u53e3\n<pre>iptables -I INPUT -p tcp -m tcp --dport 10000:20000 -j ACCEPT\niptables -I INPUT -p udp -m udp --dport 10000:20000 -j ACCEPT<\/pre>\n<p>\u7136\u540e\u522b\u5fd8\u4e86\u4fdd\u5b58\u548c\u91cd\u542fiptables<br \/>\n<code>service iptables save<\/code><br \/>\n<code>service iptables restart<\/code><\/li>\n<\/ul>\n<ul>\n<li>\u4fdd\u5b58\u89c4\u5219<\/li>\n<\/ul>\n<pre class=\"prettyprint\"><code class=\"hljs ruby has-numbering\">iptables-save &gt; <span class=\"hljs-regexp\">\/etc\/sysconfig<\/span><span class=\"hljs-regexp\">\/iptables<\/span><\/code><\/pre>\n<ul>\n<li>\u8bbe\u7f6e\u4e3a\u5f00\u673a\u542f\u52a8\u5e76\u4e14\u91cd\u542f<\/li>\n<\/ul>\n<pre class=\"prettyprint\"><code class=\"hljs avrasm has-numbering\">systemctl enable iptables<span class=\"hljs-preprocessor\">.service<\/span>\nsystemctl reboot<\/code><\/pre>\n<p>\u8fd9\u6837\u5c31\u5c06\u6240\u9700\u7684\u7aef\u53e3<code>3000<\/code>\u542f\u7528\uff0c\u8fdb\u5165\u5230\u76ee\u5f55\u4e0b\u8fd0\u884c<code>node app.js<\/code>\uff0c\u5c31\u53ef\u4ee5\u6765\u770b<code>node<\/code>demo\u5566\uff01<br \/>\n\u5b89\u5229\u4e0b\u4e00\u4e2a\u5c0f\u7684\u811a\u624b\u67b6\uff1a<br \/>\n<a href=\"https:\/\/github.com\/zp1996\/lsgo-cli\">https:\/\/github.com\/zp1996\/lsgo-cli<\/a><\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u8f6c\u8f7d\u81ea\uff1a http:\/\/blog.csdn.net\/zp1996323\/article\/details\/523&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"aside","meta":{"footnotes":""},"categories":[32],"tags":[],"class_list":["post-54","post","type-post","status-publish","format-aside","hentry","category-32","post_format-post-format-aside"],"_links":{"self":[{"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=\/wp\/v2\/posts\/54","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=54"}],"version-history":[{"count":0,"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=\/wp\/v2\/posts\/54\/revisions"}],"wp:attachment":[{"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}