{"id":250,"date":"2021-08-06T14:34:00","date_gmt":"2021-08-06T14:34:00","guid":{"rendered":"https:\/\/262235.xyz\/?p=250"},"modified":"2021-08-06T14:34:00","modified_gmt":"2021-08-06T14:34:00","slug":"250","status":"publish","type":"post","link":"https:\/\/lyvba.com\/index.php\/2021\/08\/06\/250\/","title":{"rendered":"\u7b80\u5355\u7684Linux\u547d\u4ee4\u7b14\u8bb0 ssh  ip  ss"},"content":{"rendered":"<h2>SSH \u8fdc\u7a0b\u767b\u5f55\u4e3a Secure Shell \u7684\u7f29\u5199,\u662f\u8f83\u53ef\u9760\uff0c\u4e13\u4e3a\u8fdc\u7a0b\u767b\u5f55\u4f1a\u8bdd\u548c\u5176\u4ed6\u7f51\u7edc\u670d\u52a1\u63d0\u4f9b\u5b89\u5168\u6027\u7684\u534f\u8bae\u3002<\/h2>\n<pre><code>ssh root@188.188.188.188\n\n# \u7f16\u5199\u4e00\u4e2asshr\u811a\u672c\uff0c\u6dfb\u52a0\u4e00\u884c\u5185\u5bb9\nvim \/usr\/bin\/sshr\nssh root@$1\n\n# \u6dfb\u52a0\u53ef\u6267\u884c\u5c5e\u6027\nchmod +x \/usr\/bin\/sshr\n\n# \u4f7f\u7528\u811a\u672c\u52a0IP\u5730\u5740 \u6216\u8005 \u57df\u540d\u5c31\u65b9\u4fbf\u591a\u4e86\nsshr  188.188.188.188<\/code><\/pre>\n<h2>ss\u662fSocket Statistics\u7684\u7f29\u5199\u3002\u987e\u540d\u601d\u4e49\uff0css\u547d\u4ee4\u53ef\u4ee5\u7528\u6765\u83b7\u53d6socket\u7edf\u8ba1\u4fe1\u606f<\/h2>\n<pre><code>ss -lt4   # \u663e\u793atcp ipv4\u7684 \u76d1\u542c\u7aef\u53e3\nss -ld    # \u663e\u793audp \u76d1\u542c\u7aef\u53e3<\/code><\/pre>\n<h2>ip \u547d\u4ee4\u662f Linux \u52a0\u5f3a\u7248\u7684\u7684\u7f51\u7edc\u914d\u7f6e\u5de5\u5177\uff0c\u7528\u4e8e\u4ee3\u66ff ifconfig \u547d\u4ee4<\/h2>\n<pre><code>ip addr    # \u663e\u793a\u7f51\u5361\u4fe1\u606f\u548cIP\u5730\u5740\nip addr show dev docker0   # \u663e\u793aDocker\u7f51\u5173ip\u5730\u5740<\/code><\/pre>\n<ul>\n<li>\u5e38\u7528\u5bf9\u8c61\u7684\u53d6\u503c\u542b\u4e49\u5982\u4e0b\uff1a<\/li>\n<li>link\uff1a\u7f51\u7edc\u8bbe\u5907<\/li>\n<li>address\uff1a\u8bbe\u5907\u4e0a\u7684\u534f\u8bae\uff08IP\u6216IPv6\uff09\u5730\u5740<\/li>\n<li>addrlabel\uff1a\u534f\u8bae\u5730\u5740\u9009\u62e9\u7684\u6807\u7b7e\u914d\u7f6e<\/li>\n<li>route\uff1a\u8def\u7531\u8868\u6761\u76ee<\/li>\n<li>rule\uff1a\u8def\u7531\u7b56\u7565\u6570\u636e\u5e93\u4e2d\u7684\u89c4\u5219<\/li>\n<\/ul>\n<h3>\u83b7\u53d6\u4e3b\u673a\u6240\u6709\u7f51\u7edc\u63a5\u53e3\uff1a<\/h3>\n<pre><code>ip link | grep -E '^[0-9]' | awk -F: '{print $2}'<\/code><\/pre>\n<h3>\u5176\u4ed6\u4f7f\u7528\u7528\u6cd5<\/h3>\n<pre><code>ip link show                     # \u663e\u793a\u7f51\u7edc\u63a5\u53e3\u4fe1\u606f\nip link set eth0 up             # \u5f00\u542f\u7f51\u5361\nip link set eth0 down            # \u5173\u95ed\u7f51\u5361\nip link set eth0 promisc on      # \u5f00\u542f\u7f51\u5361\u7684\u6df7\u5408\u6a21\u5f0f\nip link set eth0 promisc offi    # \u5173\u95ed\u7f51\u5361\u7684\u6df7\u4e2a\u6a21\u5f0f\nip link set eth0 txqueuelen 1200 # \u8bbe\u7f6e\u7f51\u5361\u961f\u5217\u957f\u5ea6\nip link set eth0 mtu 1400        # \u8bbe\u7f6e\u7f51\u5361\u6700\u5927\u4f20\u8f93\u5355\u5143\nip addr show     # \u663e\u793a\u7f51\u5361IP\u4fe1\u606f\nip addr add 192.168.0.1\/24 dev eth0 # \u8bbe\u7f6eeth0\u7f51\u5361IP\u5730\u5740192.168.0.1\nip addr del 192.168.0.1\/24 dev eth0 # \u5220\u9664eth0\u7f51\u5361IP\u5730\u5740\n\nip route show # \u663e\u793a\u7cfb\u7edf\u8def\u7531\nip route add default via 192.168.1.254   # \u8bbe\u7f6e\u7cfb\u7edf\u9ed8\u8ba4\u8def\u7531\nip route list                 # \u67e5\u770b\u8def\u7531\u4fe1\u606f\nip route add 192.168.4.0\/24  via  192.168.0.254 dev eth0 # \u8bbe\u7f6e192.168.4.0\u7f51\u6bb5\u7684\u7f51\u5173\u4e3a192.168.0.254,\u6570\u636e\u8d70eth0\u63a5\u53e3\nip route add default via  192.168.0.254  dev eth0        # \u8bbe\u7f6e\u9ed8\u8ba4\u7f51\u5173\u4e3a192.168.0.254\nip route del 192.168.4.0\/24   # \u5220\u9664192.168.4.0\u7f51\u6bb5\u7684\u7f51\u5173\nip route del default          # \u5220\u9664\u9ed8\u8ba4\u8def\u7531\nip route delete 192.168.1.0\/24 dev eth0 # \u5220\u9664\u8def\u7531<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>SSH \u8fdc\u7a0b\u767b\u5f55\u4e3a Secure Shell \u7684\u7f29\u5199,\u662f\u8f83\u53ef\u9760\uff0c\u4e13\u4e3a\u8fdc\u7a0b\u767b\u5f55\u4f1a\u8bdd\u548c\u5176\u4ed6\u7f51\u7edc\u670d\u52a1\u63d0\u4f9b\u5b89 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[23],"class_list":["post-250","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux"],"_links":{"self":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts\/250","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/comments?post=250"}],"version-history":[{"count":0,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts\/250\/revisions"}],"wp:attachment":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/media?parent=250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/categories?post=250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/tags?post=250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}