Use iptables firewall to shield websites from specified countries

Source: Internet
Author: User
Some servers need to deny access from IP addresses in specific countries. you can use Iptables with ipdeny to Filter IP segments from different countries as the source. a large number of IP segments may affect iptables performance, you can also use the high-efficiency Iptablesgeoip module for matching. Application example: #/bin/bashwget-O/tmp/us. zonehttp: // w some servers need to reject access from IP addresses in specific countries. you can use Iptables with ipdeny to filter the IP segments of various countries for source operations. a large number of such requests may affect IptablesPerformance. you can also use the high-efficiency Iptablesgeoip module for matching.
For example:
#/Bin/bash
Wget-O/tmp/us. zonehttp: // www.ipdeny.com/ipblocks/data/countries/us.zone
For ip in 'cat/tmp/us. zone'
Do
Blocking $ ip
Iptables-I INPUT-s $ ip-j DROP
Done

PS: The idea is for reference only, and IP data is incomplete.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.