c#阻止特定ip
The more I use the .htaccess file the more I appreciate its value. My next valuable lesson in .htaccess security deals with allowing and blocking access to a web server from a specific IP address. Reasons for doing this include:
我使用.htaccess文件越多,我就越欣赏它的价值。 关于.htaccess安全性的下一个有价值的课程是关于允许和阻止从特定IP地址访问Web服务器的。 这样做的原因包括:
- Keeping a known hacker/bot from accessing your website 防止已知的黑客/机器人访问您的网站
- Allowing only your IP address to view your website (while it's in development, for example) 仅允许您的IP地址查看您的网站(例如,正在开发中)
- Allowing only trusted persons into your website (if your users' IP's stay the same, that's more secure than user/pass) 只允许受信任的人进入您的网站(如果您的用户的IP保持不变,那将比用户/通行证更安全)
Disallowing persons from a specified country (or any known location) from your website
禁止来自您网站上指定国家(或任何已知位置)的人员
- Banning persons from your website 禁止人员进入您的网站
代码 (The Code)
<limit GET POST PUT>
order deny,allow
deny from 202.57.377.22
deny from 8.77.88.33
allow from all
</limit>
The above code bans the two IP addresses from accessing the website.
上面的代码禁止两个IP地址访问该网站。
Chances are you wont do this often. I do, however, believe that you should use this for your development server. Allowing only LAN users to access your development server prevents a search engine or hacker from getting to your website:
您很可能不会经常这样做。 但是,我确实相信您应该将此用于开发服务器。 仅允许LAN用户访问您的开发服务器可防止搜索引擎或黑客访问您的网站:
<limit GET POST PUT>
order deny,allow
deny from all
allow from 192.168.0.0/24
</limit>
Do you have any other reasons to ban IP addresses? Have any code to share? Please do!
您还有其他禁止IP地址的理由吗? 有任何代码要共享吗? 请做!
翻译自: https://davidwalsh.name/htaccess-security-allow-block-ips
c#阻止特定ip