---
name: "ether_aton"
section: "3"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/ether_aton"
---

# ether\_aton(3)

Ethernet address manipulation routines

## NAME

ether\_aton, ether\_ntoa, ether\_ntohost, ether\_hostton, ether\_line, ether\_ntoa\_r, ether\_aton\_r - Ethernet address manipulation routines

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#include <netinet/ether.h>
```

**char \*ether\_ntoa(const struct ether\_addr \****addr***);** **struct ether\_addr \*ether\_aton(const char \****asc***);**

**int ether\_ntohost(char \****hostname***, const struct ether\_addr \****addr***);** **int ether\_hostton(const char \****hostname***, struct ether\_addr \****addr***);**

**int ether\_line(const char \****line***, struct ether\_addr \****addr***,**                **char \****hostname***);**

/\* GNU extensions \*/ **char \*ether\_ntoa\_r(const struct ether\_addr \****addr***, char \****buf***);**

**struct ether\_addr \*ether\_aton\_r(const char \****asc***,**                                 **struct ether\_addr \****addr***);**

## DESCRIPTION

**ether\_aton**() converts the 48-bit Ethernet host address *asc* from the standard hex-digits-and-colons notation into binary data in network byte order and returns a pointer to it in a statically allocated buffer, which subsequent calls will overwrite. **ether\_aton**() returns NULL if the address is invalid.

The **ether\_ntoa**() function converts the Ethernet host address *addr* given in network byte order to a string in standard hex-digits-and-colons notation, omitting leading zeros. The string is returned in a statically allocated buffer, which subsequent calls will overwrite.

The **ether\_ntohost**() function maps an Ethernet address to the corresponding hostname in */etc/ethers* and returns nonzero if it cannot be found.

The **ether\_hostton**() function maps a hostname to the corresponding Ethernet address in */etc/ethers* and returns nonzero if it cannot be found.

The **ether\_line**() function parses a line in */etc/ethers* format (ethernet address followed by whitespace followed by hostname; '#' introduces a comment) and returns an address and hostname pair, or nonzero if it cannot be parsed. The buffer pointed to by *hostname* must be sufficiently long —for example, have the same length as *line*—.

The functions **ether\_ntoa\_r**() and **ether\_aton\_r**() are reentrant thread-safe versions of **ether\_ntoa**() and **ether\_aton**() respectively, and do not use static buffers.

The structure *ether\_addr* is defined in *\<net/ethernet.h\>* as:

```
struct ether_addr {
    uint8_t ether_addr_octet[6];
}
```

## ATTRIBUTES

For an explanation of the terms used in this section, see [**attributes**(7)](/attributes/7.md).

| | | |
| --- | --- | --- |
| **Interface** | **Attribute** | **Value** |
| **ether\_aton**(), **ether\_ntoa**() | Thread safety | MT-Unsafe |
| **ether\_ntohost**(), **ether\_hostton**(), **ether\_line**(), **ether\_ntoa\_r**(), **ether\_aton\_r**() | Thread safety | MT-Safe |

## STANDARDS

None.

## HISTORY

4\.3BSD, SunOS.

## BUGS

In glibc 2.2.5 and earlier, the implementation of **ether\_line**() is broken.

## SEE ALSO

[**ethers**(5)](/ethers/5.md)
