74
74
# from them; however we do not, so we should ignore them.
77
# IANA = <http://www.iana.org/assignments/ipv4-address-space>,
78
# <http://duxcw.com/faq/network/privip.htm>,
79
# APIPA = <http://duxcw.com/faq/network/autoip.htm>,
80
# 3330 = <ftp://ftp.rfc-editor.org/in-notes/rfc3330.txt>
77
# IANA = <http://www.iana.org/numbers>,
78
# 5735 = <http://tools.ietf.org/html/rfc5735>
79
# 6598 = <http://tools.ietf.org/html/rfc6598>
80
# 4193 = <http://tools.ietf.org/html/rfc4193>
81
81
# CYMRU = <http://www.cymru.com/Documents/bogon-list.html>
83
# This also includes IPv6 link-local space, fe80::/10, the IPv4
84
# spaces mapped in IPv6, and the IPv6 host-local address, ::1.
84
# host-local address space 127.0.0.0/8 and ::1,
85
# link-local address space 169.254.0.0/16 and fe80::/10,
86
# private-use address space 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16,
87
# TODO: Unique Local Unicast Addresses fc00::/7 (RFC 4193)
88
# shared address space 100.64.0.0/10 (RFC 6598 - for use in CGN),
89
# IPv4-mapped IPv6 address ::ffff:0:0/96 (RFC 3513)
86
91
use constant IP_PRIVATE => qr{^(?:
87
92
(?: # IPv4 addresses
88
10| # 10/8: Private Use (3330)
89
127| # 127/8: Private Use (localhost)
90
169\.254| # 169.254/16: Private Use (APIPA)
91
172\.(?:1[6-9]|2[0-9]|3[01])| # 172.16-172.31/16: Private Use (3330)
92
192\.168 # 192.168/16: Private Use (3330)
93
10| # 10.0.0.0/8 Private Use (5735, 1918)
94
127| # 127.0.0.0/8 Host-local (5735, 1122)
95
169\.254| # 169.254.0.0/16 Link-local (5735, 3927)
96
172\.(?:1[6-9]|2[0-9]|3[01])| # 172.16.0.0/12 Private Use (5735, 1918)
97
192\.168| # 192.168.0.0/16 Private Use (5735, 1918)
98
100\.(?:6[4-9]|[7-9][0-9]|1[01][0-9]|12[0-7]) # 100.64.0.0/10 CGN (6598)
95
101
(?: # IPv6 addresses