std.str2ip

IPstd.str2ipSTRINGaddrSTRINGfallback

Available in all subroutines.

Converts the string addr to an IP address (IPv4 or IPv6). If conversion fails, fallback will be returned.

The string must be a numeric IP address representation in the standard format, such as 192.0.2.2 or 2001:db8::1. This function does not support looking up an IP address by name.

We recommend using a fallback IP address that's meaningful for your particular Fastly service.

The inverse conversion is available as std.ip2str.

Example

if (std.str2ip("192.0.2.1", "192.0.2.2") ~ my_acl) {
...
}

User contributed notes

We welcome comments that add use cases, ideas, tips, and caveats. All comments will be moderated before publication. To post support questions, visit our support center and we'll find you the help you need.