num2ipv4() / ipv42num() — rsyslog 8.2102.0 documentation

# num2ipv4() / ipv42num()

## Purpose

### num2ipv4

num2ipv4(int)

Converts an integer into an IPv4-address and returns the address as string. Input is an integer with a value between 0 and 4294967295. The output format is ‘>decimal<.>decimal<.>decimal<.>decimal<’ and ‘-1’ if the integer input is invalid or if the function encounters a problem.

### ipv42num

ipv42num(str)

Converts an IPv4-address into an integer and returns the integer. Input is a string; the expected address format may include spaces in the beginning and end, but must not contain any other characters in between (except dots). If the format does include these, the function results in an error and returns -1.

## Example

### num2ipv4

This example shows an integer being converted to an ipv4 address.

    num2ipv4(123456)

### ipv42num

This example shows the parameter fromhost-ip being converted to an integer.

    ipv42num($fromhost-ip)

See also

Help with configuring/using `Rsyslog`:

- Mailing list - best route for general questions
- GitHub: rsyslog source project - detailed questions, reporting issues that are believed to be bugs with `Rsyslog`
- Stack Exchange (View, Ask) - experimental support from rsyslog community

See also

Contributing to `Rsyslog`:

- Source project: rsyslog project README.
- Documentation: rsyslog-doc project README

Copyright 2008-2020 Rainer Gerhards (Großrinderfeld), and Others.