Skip to main content

Address policy

AddressPolicy.IsAllowed(IPAddress) decides whether a connection may reach an address. Myelin calls it on every address a host resolves to, before connecting; one refused answer refuses the host.

Refused ranges​

Every entry of the IANA IPv4 and IPv6 special-purpose registries that is not globally reachable, plus multicast and broadcast:

IPv4What
0.0.0.0/8"This network"
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16Private
100.64.0.0/10Carrier-grade NAT
127.0.0.0/8Loopback
169.254.0.0/16Link-local, cloud metadata (169.254.169.254)
192.0.0.0/24IETF protocol assignments
192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24Documentation
192.88.99.0/24Deprecated 6to4 relay
198.18.0.0/15Benchmarking
224.0.0.0/4Multicast
240.0.0.0/4Reserved, and 255.255.255.255
IPv6What
::/96IPv4-compatible, :: and ::1
::ffff:0:0:0/96SIIT IPv4-translated
64:ff9b:1::/48Local-use NAT64
100::/64, 100:0:0:1::/64Discard-only, dummy prefix
2001::/23IETF protocol assignments (Teredo, benchmarking, ORCHID…)
2001:db8::/32, 3fff::/20Documentation
2002::/166to4
5f00::/16Segment routing SIDs
fc00::/7Unique local
fe80::/10, fec0::/10Link-local, deprecated site-local
ff00::/8Multicast

An application that must call a service it registered itself on a private network can opt in to registered endpoints: exact https host:port pairs allowed to reach private-use, CGNAT and unique-local addresses, and nothing else.

192.0.0.0/24 and 2001::/23 are refused whole, including the few anycast services they hold: an application has no reason to call them.

Mapped and translated addresses​

  • IPv4-mapped (::ffff:a.b.c.d) is judged on its IPv4 address: ::ffff:10.0.0.1 is refused, ::ffff:8.8.8.8 allowed.
  • Well-known NAT64 (64:ff9b::/96) is judged on the IPv4 address it embeds, so a NAT64 network still reaches public IPv4 hosts and still cannot reach 10.0.0.1.

The ranges are checked with System.Net.IPNetwork on parsed addresses, never on text: octal, hexadecimal and integer notations (0x7f000001, 2130706433) are already 127.0.0.1 by then.

DNS rebinding​

The connection handler (MyelinHandler.Create) resolves the host itself, checks every answer, then opens the socket on exactly those addresses. The socket layer never resolves the name again, so a server that answers a public address to the check and a private one to the connection gains nothing.

Proxies are disabled for the same reason: a proxy would connect to an address this check never sees.

Custom resolution​

Register your own IHostResolver (before AddMyelin, or in place of the default) to resolve through another DNS service, or to make tests deterministic:

services.AddSingleton<IHostResolver, MyResolver>();
services.AddMyelin();