1. 程式人生 > >通過IP歸屬地過濾Linux服務器端口流量

通過IP歸屬地過濾Linux服務器端口流量

歸屬地 linux 過濾

一、IP歸屬地數據庫中導出需要的地址段列表

二、安裝ipset

三、建立access白名單

ipset create access hash:net

四、導入IP地址

use strict;

open INPUT,"output.txt";
while (<INPUT>){
        my $line=$_;
        chomp $line;
        system ("ipset add access $line");
}
close INPUT;

五、設置iptables規則

iptables -A INPUT -m set --match-set access src -p udp --destination-port 53 -j ACCEPT
iptables -A INPUT -p udp --destination-port 53 -j DROP


本文出自 “如意靈臨” 博客,請務必保留此出處http://417722381.blog.51cto.com/7856838/1971479

通過IP歸屬地過濾Linux服務器端口流量