Question

I have an application which must warn the user upon use of localhost, 127.0.0.1, ::1, or any loopback address (the target host is used for a database-to-database connection not necessarily inside of the environment of the application). This is made complicated because addresses like the following...

  • 127.1
  • 127.0.01
  • 127.0000.0000.1
  • 127.0.0.254
  • 127.63.31.15
  • 127.255.255.254
  • 0::1
  • 0000::0001
  • 0000:0:0000::01
  • 0000:0000:0000:0000:0000:0000:0000:0001

...will parse properly by the consuming code, and will resolve to loopback.

What is a regular expression which will match any permutation of the IPv4 and IPv6 loopback addresses?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top