{"id":20743,"date":"2023-09-02T09:16:18","date_gmt":"2023-09-02T01:16:18","guid":{"rendered":"\/\/www.dealsbon.com\/?p=20743"},"modified":"2023-09-02T09:16:18","modified_gmt":"2023-09-02T01:16:18","slug":"lpz","status":"publish","type":"post","link":"\/\/www.dealsbon.com\/blog\/20743.html","title":{"rendered":"LinuxSNMP\u914d\u7f6e"},"content":{"rendered":"

  SNMP\uff08\u7b80\u5355\u7f51\u7edc\u7ba1\u7406\u534f\u8bae\uff09\u662f\u4e00\u79cd\u5e94\u7528\u4e8e\u7f51\u7edc\u7ba1\u7406\u7684\u534f\u8bae\uff0c\u5b83\u53ef\u4ee5\u8ba9\u7f51\u7edc\u7ba1\u7406\u5458\u5728Linux\u7cfb\u7edf\u4e2d\u83b7\u53d6\u548c\u8bbe\u7f6e\u7f51\u7edc\u8bbe\u5907\u4e0a\u7684\u53c2\u6570\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5728Linux\u7cfb\u7edf\u4e2d\u5982\u4f55\u914d\u7f6eSNMP\uff0c\u4ee5\u53ca\u5982\u4f55\u4f7f\u7528SNMP\u6765\u7ba1\u7406\u7f51\u7edc\u8bbe\u5907\u3002<\/p>\n

\u5b89\u88c5\u548c\u914d\u7f6eSNMP<\/h2>\n

  \u8981\u5728Linux\u7cfb\u7edf\u4e2d\u4f7f\u7528SNMP\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5\u548c\u914d\u7f6eSNMP\u670d\u52a1\u5668\u3002\u5728Debian\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528apt-get\u547d\u4ee4\u5b89\u88c5snmpd\u670d\u52a1\uff1a<\/p>\n

  sudo apt-get install snmpd<\/p>\n

  \u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u7f16\u8f91\u5668\u7f16\u8f91\/etc\/snmp\/snmpd.conf\u6587\u4ef6\uff0c\u6765\u914d\u7f6eSNMP\u670d\u52a1\u5668\u3002\u914d\u7f6e\u6587\u4ef6\u7684\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n

  rocommunity public default -V systemonly<\/p>\n

  rwcommunity private default -V systemonly<\/p>\n

  rocommunity\u548crwcommunity\u53c2\u6570\u5206\u522b\u8868\u793a\u53ea\u8bfb\u548c\u8bfb\u5199\u8bbf\u95ee\u7684\u793e\u533a\u540d\u79f0\uff0cdefault\u8868\u793a\u8fd9\u4e2a\u793e\u533a\u53ef\u4ee5\u4ece\u4efb\u4f55\u5730\u5740\u8bbf\u95ee\uff0c\u800c-V systemonly\u8868\u793a\u53ea\u5141\u8bb8\u672c\u5730\u7cfb\u7edf\u8bbf\u95ee\u3002<\/p>\n

\u4f7f\u7528SNMP\u7ba1\u7406\u7f51\u7edc\u8bbe\u5907<\/h2>\n

  \u5b89\u88c5\u548c\u914d\u7f6eSNMP\u670d\u52a1\u5668\u540e\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528SNMP\u6765\u7ba1\u7406\u7f51\u7edc\u8bbe\u5907\u4e86\u3002SNMP\u534f\u8bae\u63d0\u4f9b\u4e86\u4e24\u79cd\u7ba1\u7406\u6a21\u5f0f\uff1a\u53ea\u8bfb\u6a21\u5f0f\u548c\u8bfb\u5199\u6a21\u5f0f\u3002\u53ea\u8bfb\u6a21\u5f0f\u53ef\u4ee5\u7528\u6765\u67e5\u770b\u7f51\u7edc\u8bbe\u5907\u4e0a\u7684\u53c2\u6570\uff0c\u800c\u8bfb\u5199\u6a21\u5f0f\u53ef\u4ee5\u7528\u6765\u66f4\u6539\u7f51\u7edc\u8bbe\u5907\u4e0a\u7684\u53c2\u6570\u3002<\/p>\n

\u53ea\u8bfb\u6a21\u5f0f<\/h3>\n

  \u5728\u53ea\u8bfb\u6a21\u5f0f\u4e0b\uff0c\u53ef\u4ee5\u4f7f\u7528snmpget\u547d\u4ee4\u67e5\u770b\u7f51\u7edc\u8bbe\u5907\u4e0a\u7684\u53c2\u6570\uff0c\u4f8b\u5982\uff1a<\/p>\n

  snmpget -v 1 -c public 192.168.1.1 sysDescr.0<\/p>\n

  \u8fd9\u6761\u547d\u4ee4\u4f1a\u8fd4\u56de\u8bbe\u5907\u7684\u63cf\u8ff0\u4fe1\u606f\uff1a<\/p>\n

  sysDescr.0 = STRING: “Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 12.2(25)FX, RELEASE SOFTWARE (fc1)” <\/p>\n

\u8bfb\u5199\u6a21\u5f0f<\/h3>\n

  \u5728\u8bfb\u5199\u6a21\u5f0f\u4e0b\uff0c\u53ef\u4ee5\u4f7f\u7528snmpset\u547d\u4ee4\u6765\u66f4\u6539\u7f51\u7edc\u8bbe\u5907\u4e0a\u7684\u53c2\u6570\uff0c\u4f8b\u5982\uff1a<\/p>\n

  snmpset -v 1 -c private 192.168.1.1 sysContact.0 s “admin@example.com”<\/p>\n

  \u8fd9\u6761\u547d\u4ee4\u4f1a\u5c06\u8bbe\u5907\u7684\u8054\u7cfb\u4eba\u4fe1\u606f\u8bbe\u7f6e\u4e3aadmin@example.com\u3002<\/p>\n

\u603b\u7ed3<\/h2>\n

  \u672c\u6587\u4ecb\u7ecd\u4e86\u5982\u4f55\u5728Linux\u7cfb\u7edf\u4e2d\u914d\u7f6e\u548c\u4f7f\u7528SNMP\u534f\u8bae\u6765\u7ba1\u7406\u7f51\u7edc\u8bbe\u5907\u3002<\/strong>\u901a\u8fc7SNMP\u534f\u8bae\uff0c\u53ef\u4ee5\u5b9e\u73b0\u8fdc\u7a0b\u76d1\u63a7\u548c\u7ba1\u7406\u7f51\u7edc\u8bbe\u5907\uff0c\u63d0\u9ad8\u7f51\u7edc\u7ba1\u7406\u7684\u6548\u7387\u548c\u53ef\u9760\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

SNMP\uff08\u7b80\u5355\u7f51\u7edc\u7ba1\u7406\u534f\u8bae\uff09\u662f\u4e00\u79cd\u5e94\u7528\u4e8e\u7f51\u7edc\u7ba1\u7406\u7684\u534f\u8bae\uff0c\u5b83\u53ef\u4ee5\u8ba9\u7f51\u7edc\u7ba1\u7406\u5458\u5728Linux\u7cfb\u7edf\u4e2d\u83b7\u53d6\u548c\u8bbe\u7f6e\u7f51\u7edc\u8bbe\u5907\u4e0a\u7684\u53c2\u6570\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5728Linux\u7cfb\u7edf\u4e2d\u5982\u4f55\u914d\u7f6eSNMP\uff0c\u4ee5\u53ca<\/p>\n","protected":false},"author":1,"featured_media":3671,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"categories":[36],"tags":[81],"class_list":["post-20743","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-snmp"],"_links":{"self":[{"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/posts\/20743"}],"collection":[{"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/comments?post=20743"}],"version-history":[{"count":0,"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/posts\/20743\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/media\/3671"}],"wp:attachment":[{"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/media?parent=20743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/categories?post=20743"},{"taxonomy":"post_tag","embeddable":true,"href":"\/\/www.dealsbon.com\/wp-json\/wp\/v2\/tags?post=20743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}