List of North America IP blocks for ipset

Feb 3, 2012 00:00 · 189 words · 1 minute read Linux Networking

Some short list of ip blocks (with ipset commands) allocated for North America. This list is not 100% accurate, but it works for me.

ipset create na-networks hash:net hashsize 32 maxelem 512
ipset add na-networks 23.0.0.0/8 
ipset add na-networks 24.0.0.0/8 
ipset add na-networks 50.0.0.0/8
ipset add na-networks 63.0.0.0/8
ipset add na-networks 64.0.0.0/8
ipset add na-networks 65.0.0.0/8
ipset add na-networks 66.0.0.0/8
ipset add na-networks 67.0.0.0/8
ipset add na-networks 68.0.0.0/8
ipset add na-networks 69.0.0.0/8
ipset add na-networks 70.0.0.0/8
ipset add na-networks 71.0.0.0/8
ipset add na-networks 72.0.0.0/8
ipset add na-networks 73.0.0.0/8
ipset add na-networks 74.0.0.0/8
ipset add na-networks 75.0.0.0/8
ipset add na-networks 76.0.0.0/8
ipset add na-networks 96.0.0.0/8
ipset add na-networks 97.0.0.0/8
ipset add na-networks 98.0.0.0/8
ipset add na-networks 98.0.0.0/8
ipset add na-networks 100.0.0.0/8
ipset add na-networks 107.0.0.0/8
ipset add na-networks 108.0.0.0/8
ipset add na-networks 173.0.0.0/8
ipset add na-networks 174.0.0.0/8
ipset add na-networks 184.0.0.0/8
ipset add na-networks 199.0.0.0/8
ipset add na-networks 204.0.0.0/8
ipset add na-networks 205.0.0.0/8
ipset add na-networks 206.0.0.0/8
ipset add na-networks 207.0.0.0/8
ipset add na-networks 208.0.0.0/8
ipset add na-networks 209.0.0.0/8
ipset add na-networks 216.0.0.0/8

How to use it? Easy:

iptables -A INPUT -p icmp -m set --match-set na-networks src -j ACCEPT