Block or unblock: ip, range, subnet, contries trong iptables (block ip nuoc ngoai)
Block or unblock: ip, range, subnet, contries trong iptables (block ip nuoc ngoai)
1. Block 1 dia chi IP Following iptable rule will drop incoming connection from host/IP 202.54.20.22: Trích dẫn:
2. Block day IP a. su dung command Trích dẫn:
b. Edit file /etc/sysconfig/iptables them vao Trích dẫn:
3. Block tat ca ip trong danh sach chi dinh Cach 1: If you have lots of IP address use the following shell script: A) Tao file: Trích dẫn:
# Ip address block file Trích dẫn:
B) Tao doan script nhu sau va them vao file iptables: Trích dẫn:
# /etc/init.d/iptables restart Cach 2: Nếu bạn đang đối mặt với rất nhiều cuộc tấn công, tốt hơn hết bạn nên sử dụng một phương pháp tự động hơn để thêm địa chỉ IP từ danh sách cấm. Để làm việc này, ta tạo đoạn mã sau: #!/bin/sh for i in $(< banned_IPs.cfg) ; do iptables -I INPUT -i eth1 -s "$i" -j DROP done Lưu đoạn mã trên vào một file với tên bất kì như banned_IPs.sh và gán cho nó quyền thực thi: # chmod +x banned_IPs.sh Bây giờ tạo một file banned_IPs.cfg và nhập vào danh sách địa chỉ IP bạn muốn khóa, mỗi cái trên một dòng: 122.174.12.228 129.122.10.23 111.154.84.130 Bây giờ chạy file banned_IPs.sh để đưa địa chỉ IP bạn muốn khóa thêm vào danh sách IP cấm trong iptables: # ./banned_IPs.sh Chúc Vui vẻ ! 4.Unblock / Delete an IP Address Listed in IPtables Tables List existing chains Type the following command to list current IPs in tables: Trích dẫn:
List existing chains with line number To display line number along with other information, enter: iptables -L INPUT -n --line-numbers iptables -L OUTPUT -n --line-numbers iptables -L OUTPUT -n --line-numbers | less iptables -L spamips -n -v --line-numbers iptables -L spamips -n -v --line-numbers | grep 202.54.1.2 Trích dẫn:
iptables -D INPUT 10 You can also use the following syntax to delete / unblock an IP use the following syntax: iptables -D INPUT -s xx.xxx.xx.xx -j DROP iptables -D INPUT -s xx.xxx.xx.xx/yy -j DROP iptables -D spamlist -s 202.54.1.2 -d 0/0 -j DROP iptables -D spamlist -s 202.54.1.2/29 -d 0/0 -j DROP http://www.cyberciti.biz/faq/block-e...sing-iptables/ 5. Block IP nuoc ngoai Tạo tập tin #vi /root/country.block.iptables.sh với nội dung như bên dưới: Chú y: Điền mã nước mà bạn muốn chặn vào phần: ISO= Xem mã nước: http://www.iana.org/domains/root/db/ Trích dẫn:
Lập lịch cho file này chạy một tuần 1 lần Trích dẫn:
Chạy ngay không cần lập lịch Trích dẫn:
Chúc bạn thành công! :battay: tham khao: Range IP của các nước http://www.find-ip-address.org/ip-country/ http://ipinfodb.com/ip_country_block_iptables.php http://www.cyberciti.biz/faq/block-e...sing-iptables/ http://howtoforge.com/blocking-ip-addresses-of-any-country-with-iptables http://www.cyberciti.biz/faq/samba-r...-to-ipc-share/ :battay: |
3 серая толстовка
|
Bây giờ là 04:44 PM. Giờ GMT +7 |
Diễn đàn tin học QuantriNet
quantrinet.com | quantrimang.co.cc
Founded by Trương Văn Phương | Developed by QuantriNet's members.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.