dnscontrol/docs/_functions/global/IP.md
Jed Fox 1e337abcdf
Provide TypeScript typings for dnsconfig.js (#1830)
Co-authored-by: Jeffrey Cafferata <jeffrey@jcid.nl>
Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
2023-01-12 16:59:42 -05:00

35 lines
674 B
Markdown

---
name: IP
parameters:
- ip
parameter_types:
ip: string
return: number
---
Converts an IPv4 address from string to an integer. This allows performing mathematical operations with the IP address.
{% capture example %}
```js
var addrA = IP('1.2.3.4')
var addrB = addrA + 1
// addrB = 1.2.3.5
```
{% endcapture %}
{% include example.html content=example %}
NOTE: `IP()` does not accept IPv6 addresses (PRs gladly accepted!). IPv6 addresses are simply strings:
{% capture example2 %}
```js
// IPv4 Var
var addrA1 = IP("1.2.3.4");
var addrA2 = "1.2.3.4";
// IPv6 Var
var addrAAAA = "0:0:0:0:0:0:0:0";
```
{% endcapture %}
{% include example.html content=example2 %}