Link-local address/Linux
Appearance
A link-local address is an Internet Protocol (IP) unicast address intended to be used only to connect to the hosts on the same network, or link (such as an Ethernet one) as the given host. The activities below are intended to show how to view and test IP link-local addresses in Linux-based systems.
Readings
[edit | edit source]- Link-local address at Wikipedia.
- Manual pages:
- ip-address(8);
- ping6(8) (also covers the
ping
command); - avahi-autoipd(8).
Preparation
[edit | edit source]To prepare for this activity:
- ensure that the Linux-based system of choice is started;
- log into the system.
Conventions
[edit | edit source]The commands available to non-privileged users are from now on written as $ command
(where $
is the shell prompt, and is not to be typed.)
The commands available only to the privileged users are written as # command
(where #
is again not to be typed.) Depending on the configuration, you may be able to execute them either of the following ways:
- by using
$ sudo command
(and entering your own user password); - by using
$ su -c 'command'
(and entering the “root” password); - by logging in as
root
, or switching there with either$ sudo -i
or$ su
, and entering the command directly into the resulting privileged shell; - not at all, if you are not authorized to perform administrative tasks on the host in question.
Activities
[edit | edit source]Check currently assigned addresses
[edit | edit source]- Use
$ ip address list
(or simply$ ip a
) to view all the addresses currently assigned to the system’s interfaces. - The output is expected to contain a section for the local loopback interface (named
lo
), and a section for an Ethernet network interface controllers (henceforth assumed to be namedeth0
.) - Examine this latter section to find entries for link-local, globally-routable IPv6, and all the IPv4 addresses, and compare them to the following examples.
inet6 fe80::349d:33ff:fe76:2cee/64 scope link
- This is a IPv6 link-local address, as indicated by:
- its
fe80::/64
network prefix; - the explicit
scope link
flag.
- its
inet 169.254.46.5/16 brd 169.254.255.255 scope global eth0
- A link-local IPv4 address, as indicated by its
169.254.0.0/16
prefix. inet6 2001:db8:42::349d:33ff:fe76:2cee/64 scope global
- A globally-routable IPv6 address, as indicated by the explicit
scope global
flag. inet 192.0.2.34/24 brd 192.0.2.255 scope global eth0
- A non-link-local IPv4 address, which may have been assigned either manually, or via DHCP.
- Note that while link-local addresses are essential for IPv6 operation (and thus are expected to be found whenever IPv6 is configured on the host), IPv4 link-local addresses are generally only found when no other addresses are available for an interface.
Test connectivity
[edit | edit source]- If a globally-routable IPv6 address was found to be available at the previous step, test IPv6 connectivity with
$ ping6 -c 3 2001:4860:4860::8888
. - If a non-link-local IPv4 address was found to be available, test IPv4 connectivity with
$ ping -c 3 8.8.8.8
. - Either or both pings are expected to report 0% packet loss.
Obtain an IPv4 link-local address
[edit | edit source]- Note that link-local addresses are essential for IPv6 operation, and thus are expected to be already available, provided that IPv6 networking is configured on the host.
- Check if the IPv4 link-local address daemon is already started for the interface with
$ ps -o pid,cmd -C avahi-autoipd
.- If yes, you may wish to stop one and start it anew. In order to do that:
- record the exact command used to start it (as shown by the previous
ps
command), so to be able to restart it afterwards; - stop it with
# avahi-autoipd --kill eth0
and start again with the command below.
- record the exact command used to start it (as shown by the previous
- If no, start the daemon with
# avahi-autoipd --force-bind -D eth0
.
- If yes, you may wish to stop one and start it anew. In order to do that:
- Check the
$ ip address list
output to ensure that an IPv4 address in the169.254.0.0/16
range is indeed assigned toeth0
.
Test link-local connectivity
[edit | edit source]- Test link-local connectivity by pinging another host on the same network with the following commands.
- Note that you need to find out that host’s exact link-local addresses beforehand; the addresses shown below are examples and are unlikely to work on any given network.
- If IPv6 is available, use
$ ping6 -c 3 fe80::7c9a:12ff:fe82:18e6
. - Use
$ ping -c 3 169.254.116.12
. - Either or both pings are expected to report 0% packet loss.
Reverting the run-time configuration changes
[edit | edit source]- If the IPv4 link-local address daemon was previously started, you may need to revert the changes thus made to the run-time configuration. Skip this section otherwise.
- Stop the currently running daemon with
# avahi-autoipd --kill eth0
. - If the daemon was previously stopped, use the command line recorded to start it again.
Test link-local connectivity
[edit | edit source]- Test link-local connectivity, or absence thereof, by pinging another host on the same network with the following commands.
- Note that you need to find out that host’s exact link-local addresses beforehand; the addresses shown below are examples and are unlikely to work on any given network.
- If IPv6 is available, use
$ ping6 -c 3 fe80::7c9a:12ff:fe82:18e6
. It’s expected to report 0% packet loss. - Use
$ ping -c 3 169.254.116.12
. It’s expected to report either 100% packet loss if no IPv4 link-local address daemon is currently running, or 0% packet loss otherwise.