@@ -62,15 +62,51 @@ var privateIPBlocks []*net.IPNet
6262
6363func init () {
6464 for _ , cidr := range []string {
65- "0.0.0.0/32" , // Linux treats 0.0.0.0 as 127.0.0.1
66- "127.0.0.0/8" , // IPv4 loopback
67- "10.0.0.0/8" , // RFC1918
68- "172.16.0.0/12" , // RFC1918
69- "192.168.0.0/16" , // RFC1918
70- "169.254.0.0/16" , // RFC3927
71- "::1/128" , // IPv6 loopback
72- "fe80::/10" , // IPv6 link-local
73- "fc00::/7" , // IPv6 unique local addr
65+ // IPv4 Special-Purpose Address Space
66+ // Address ranges taken from https://www.iana.org/assignments/iana-ipv4-special-registry/
67+ // that have the "Globally Reachable" flag marked as "False".
68+ "0.0.0.0/8" , // "This network" [RFC791], Section 3.2
69+ "10.0.0.0/8" , // Private-Use [RFC1918]
70+ "100.64.0.0/10" , // Shared Address Space [RFC6598]
71+ "127.0.0.0/8" , // Loopback [RFC1122], Section 3.2.1.3
72+ "169.254.0.0/16" , // Link Local [RFC3927]
73+ "172.16.0.0/12" , // Private-Use [RFC1918]
74+ // The 192.0.0.0/24 block does include the addresses 192.0.0.9 &
75+ // 192.0.0.10, these are marked as "Globally Reachable" but are
76+ // for such specific protocols that blocking them will not
77+ // affect flux scripts.
78+ "192.0.0.0/24" , // IETF Protocol Assignments [RFC6890], Section 2.1
79+ "192.0.2.0/24" , // Documentation (TEST-NET-1) [RFC5737]
80+ "192.88.99.2/32" , // 6a44-relay anycast address [RFC6751]
81+ "192.168.0.0/16" , // Private-Use [RFC1918]
82+ "198.18.0.0/15" , // Benchmarking [RFC2544]
83+ "198.51.100.0/24" , // Documentation (TEST-NET-2) [RFC5737]
84+ "203.0.113.0/24" , // Documentation (TEST-NET-3) [RFC5737]
85+ "240.0.0.0/4" , // Reserved [RFC1112], Section 4
86+ "255.255.255.255/32" , // Limited Broadcast [RFC8190] [RFC919], Section 7
87+
88+ // IPv6 Special-Purpose Address Space
89+ // Address ranges taken from https://www.iana.org/assignments/iana-ipv6-special-registry/
90+ // that have the "Globally Reachable" flag marked as "False".
91+ "::1/128" , // Loopback Address [RFC4291]
92+ "::/128" , // Unspecified Address [RFC4291]
93+ // The IPv4-mapped Address block is marked as not being globally
94+ // reachable, but is also how Go stores IPv4 Addresses, so
95+ // adding the range causes all IPv4 addresses to be blocked.
96+ // "::ffff:0:0/96", IPv4-mapped Address [RFC4291]
97+ "64:ff9b:1::/48" , // IPv4-IPv6 Translat. [RFC8215]
98+ "100::/64" , // Discard-Only Address Block [RFC6666]
99+ "100:0:0:1::/64" , // Dummy IPv6 Prefix [RFC9780]
100+ // The 2001::/23 block includes a number of ranges which are
101+ // marked as "Globally Reachable" but are for such specific
102+ // protocols that blocking them will not affect flux scripts.
103+ "2001::/23" , // IETF Protocol Assignments [RFC2928]
104+ "2001:db8::/32" , // Documentation [RFC3849]
105+ "2002::/16" , // 6to4 [RFC3056]
106+ "3fff::/20" , // Documentation [RFC9637]
107+ "5f00::/16" , // Segment Routing (SRv6) SIDs [RFC9602]
108+ "fc00::/7" , // Unique-Local [RFC4193] [RFC8190]
109+ "fe80::/10" , // Link-Local Unicast [RFC4291]
74110 } {
75111 _ , block , err := net .ParseCIDR (cidr )
76112 if err != nil {
0 commit comments