ether_aton - Linux


Overview

ether_aton converts a MAC (Media Access Control) address (in string format) to a network byte order integer. It is commonly used to convert MAC addresses from text form to a binary representation for network-related operations.

Syntax

ether_aton ADDRESS [RETURN]

Parameters

  • ADDRESS: The MAC address in string format, using the following format: XX:XX:XX:XX:XX:XX, where each XX represents a hexadecimal digit.
  • RETURN (Optional): The name of a variable to store the converted integer in network byte order. If omitted, the converted integer is printed to the standard output.

Options/Flags

None

Examples

Basic Usage:

ether_aton 00:11:22:33:44:55

Storing Result in a Variable:

ether_aton 00:11:22:33:44:55 test_var
echo $test_var
174439149

Complex Usage:

mac_address="00:11:22:33:44:55"
ether_aton "$mac_address" mac_int
ifconfig eth0 hw ether $mac_int

Common Issues

  • Invalid MAC Address Format: Ensure the input MAC address is in the correct format (XX:XX:XX:XX:XX:XX).
  • Network Byte Order: The converted integer is in network byte order, which may not be the expected format for all applications.

Integration

With ifconfig: Set the MAC address of a network interface using the converted integer.

ip link set eth0 down
ether_aton 00:11:22:33:44:55 mac_int
ifconfig eth0 hw ether $mac_int
ip link set eth0 up

Related Commands

  • arp: Display and manipulate ARP (Address Resolution Protocol) entries.
  • ifconfig: Display and configure network interface parameters.