{"id":370,"date":"2021-08-21T14:41:23","date_gmt":"2021-08-21T14:41:23","guid":{"rendered":"https:\/\/262235.xyz\/?p=370"},"modified":"2021-08-21T14:41:23","modified_gmt":"2021-08-21T14:41:23","slug":"370","status":"publish","type":"post","link":"https:\/\/lyvba.com\/index.php\/2021\/08\/21\/370\/","title":{"rendered":"add_ipset.sh  \u6279\u91cf\u4ece iplist \u6309\u884c\u5bfc\u5165 ipset"},"content":{"rendered":"<h3><code>add_ipset.sh<\/code><\/h3>\n<pre><code>#!\/bin\/bash\n# add_ipset.sh  \u6279\u91cf\u4ece iplist \u6309\u884c\u5bfc\u5165 ipset\n\nlet i=1\n\nwhile read -r line || [[ -n $line ]]; do\n  echo -e \"${i}  ${line}\"  &amp;&amp;  let i++\n  ipset add blacklist $line\ndone &lt; $1\n\n#########################################################################################\n#  ipset create blacklist hash:net maxelem 1000000    # 1.\u521b\u5efa\u4e00\u4e2aipset \u9ed1\u540d\u5355\n#  ipset create whitelist hash:net maxelem 1000000    # \u767d\u540d\u5355\n\n#  ipset list  #  ipset list blacklist    # 2.\u67e5\u770b\u5df2\u521b\u5efa\u7684ipset\n\n#  ipset add blacklist 10.60.10.xx        # 3.\u52a0\u5165\u4e00\u4e2a\u540d\u5355ip\n\n#  ipset del blacklist 10.60.10.xx        # 4.\u53bb\u9664\u540d\u5355ip\n\n#  5.\u521b\u5efa\u9632\u706b\u5899\u89c4\u5219\uff0c\u4e0e\u6b64\u540c\u65f6\uff0callset\u8fd9\u4e2aIP\u96c6\u91cc\u7684ip\u90fd\u65e0\u6cd5\u8bbf\u95ee80\u7aef\u53e3\uff08\u5982\uff1aCC\u653b\u51fb\u53ef\u7528\uff09\n#  iptables -I INPUT -m set --match-set blacklist src -p tcp -j DROP\n#  iptables -I INPUT -m set --match-set whitelist src -p tcp -j DROP\n#  service iptables save\n#  iptables -I INPUT -m set --match-set setname src -p tcp \u2013destination-port 80 -j DROP\n\n#  ipset save blacklist -f blacklist.txt          #  6.\u5c06ipset\u89c4\u5219\u4fdd\u5b58\u5230\u6587\u4ef6\n#  ipset save whitelist -f whitelist.txt\n\n#  ipset destroy blacklist   #  ipset restore -f whitelist.txt     # 7.\u5220\u9664ipset\n\n#  ipset restore -f blacklist.txt    # 8.\u5bfc\u5165ipset\u89c4\u5219\n#########################################################################################<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>add_ipset.sh #!\/bin\/bash # add_ipset.sh \u6279\u91cf\u4ece iplist [&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":[],"class_list":["post-370","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts\/370","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=370"}],"version-history":[{"count":0,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/posts\/370\/revisions"}],"wp:attachment":[{"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/media?parent=370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/categories?post=370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lyvba.com\/index.php\/wp-json\/wp\/v2\/tags?post=370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}