Link-local address/Linux

From Wikiversity
Jump to: navigation, search

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]

Preparation[edit]

To prepare for this activity:

  1. ensure that the Linux-based system of choice is started;
  2. log into the system.

Conventions[edit]

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]

Check currently assigned addresses[edit]

  1. Use $ ip address list (or simply $ ip a) to view all the addresses currently assigned to the system’s interfaces.
  2. 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 named eth0.)
  3. 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:
    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.
  4. 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]

  1. 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.
  2. If a non-link-local IPv4 address was found to be available, test IPv4 connectivity with $ ping -c 3 8.8.8.8.
  3. Either or both pings are expected to report 0% packet loss.

Obtain an IPv4 link-local address[edit]

  1. 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.
  2. Check if the IPv4 link-local address daemon is already started for the interface with $ ps -o pid,cmd -C avahi-autoipd.
    1. If yes, you may wish to stop one and start it anew. In order to do that:
      1. record the exact command used to start it (as shown by the previous ps command), so to be able to restart it afterwards;
      2. stop it with # avahi-autoipd --kill eth0 and start again with the command below.
    2. If no, start the daemon with # avahi-autoipd --force-bind -D eth0.
  3. Check the $ ip address list output to ensure that an IPv4 address in the 169.254.0.0/16 range is indeed assigned to eth0.

Test link-local connectivity[edit]

  1. Test link-local connectivity by pinging another host on the same network with the following commands.
  2. 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.
  3. If IPv6 is available, use $ ping6 -c 3 fe80::7c9a:12ff:fe82:18e6.
  4. Use $ ping -c 3 169.254.116.12.
  5. Either or both pings are expected to report 0% packet loss.

Reverting the run-time configuration changes[edit]

  1. 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.
  2. Stop the currently running daemon with # avahi-autoipd --kill eth0.
  3. If the daemon was previously stopped, use the command line recorded to start it again.

Test link-local connectivity[edit]

  1. Test link-local connectivity, or absence thereof, by pinging another host on the same network with the following commands.
  2. 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.
  3. If IPv6 is available, use $ ping6 -c 3 fe80::7c9a:12ff:fe82:18e6. It’s expected to report 0% packet loss.
  4. 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.

See also[edit]