Follow by Email

Blog Archive

Search This Blog

Raspberry Pi Set static IPv6 address

Raspberry Pi Set static / fixed IPv6 address If you activate IPv6 in the Raspberry Pi, it has the disadvantage that there is a rather complicated IPv6 address that you can barely remember.
Share it:
Raspberry Pi: Set static / fixed IPv6 address
Raspberr Pi-static-IPv6-address

If you activate IPv6 in Raspberry Pi, it has the disadvantage that there is a rather complicated IPv6 address that you can barely remember. If you use Raspberry Pi as a client, that's no problem. But if you want to operate Raspberry Pi as a server within the local network or often want to access it via SSH, then a static IPv6 address would be an advantage.
Of course, this assumes that IPv6 is enabled and works at least on the local network.
Note: If you configure static IP addresses, they should not come from the DHCP pool of a DHCP server.
  • Determine a free IPv6 address.
  • Change the IPv6 configuration to static.
  • Check if a connection to the static IPv6 address is possible.
Note: Disable DHCP Client Daemon
For this solution to work under Raspbian Jessie, the DHCP client daemon must be disabled.
sudo service dhcpcd stop

sudo update-rc.d -f dhcpcd remove

The latter command ensures that the "dhcpcd" is no longer started at boot time and that only the content of the file "/ etc / network / interfaces" is taken into account in the network configuration.

Note: Name of the network interfaces
Since Raspbian Stretch, the Ethernet and WLAN network interfaces have different names. So no longer "eth0" and "wlan0", but "enx ..." and "wlx ...". This concerns USB-connected network adapters whose names differ from the designations mentioned here. This means that one must first determine the individual name or change the naming to the old method.
Solution: Static IPv6 address
Right at the beginning, it should be pointed out that a network interface can and has multiple IPv6 addresses. With IPv4 it is different. Here, an interface can only ever have one IPv4 address.

What this is about is making a Raspberry Pi available on a local network under a static, link-local IPv6 address.

To do this, we open the configuration file with the IP settings.
sudo nano / etc / network / interfaces

There we enter the following lines:
# IPv6
iface eth0 inet6 static
Pre-up modprobe ipv6
address fe80 :: 1
netmask 64

There is nothing wrong with assuming these lines exactly like that. All you have to do is make sure you do not use the IPv6 address on the network before.

Then save and close: Ctrl + O, Return, Ctrl + X.

Then you have to restart Raspberry Pi.
sudo reboot

After rebooting, look for what's in the network settings in there.

The eth0 interface should now have an inet6 address with fe80 :: 1/64 and a connectivity scope.

If you've been on Raspberry Pi via SSH before, it makes sense to stop using the IPv4 address instead of the static, link-local IPv6 address.

Depending on the SSH client, one or the other will fail. An example with an SSH client on the command line:
ssh -6 pi @ fe80 :: 1

gives the following error message:
ssh: connect to host fe80 :: 1 port 22: No route to host

This error message is a pretty bland error message. Pretty much everything can be wrong here. But, unless you have done nothing wrong with the configuration, everything is in the green.
What you need to know here: If you want to establish a connection via IPv6 somewhere, then you have to specify not only the address, but also the network interface over which the connection is to be established.

The SSH client must therefore be called as follows:
ssh -6 pi @ fe80 :: 1% en1

After the "%" the interface shortcut must follow over which an IPv6-Connectivity is possible. The abbreviation can also be called "eth0", "wlan0" or otherwise. For this you should look on the local command line with "ifconfig" (Linux, Mac OS) or "ipconfig" (Windows).

Extension: access Raspberry Pi via hostname (Zeroconf / Bonjour / Avahi)
If you do not want to work with IP addresses and their configuration, you can also solve the problem with Zeroconf. With Zeroconf, also called Bonjour or Avahi, one can establish within the local network a connection to Raspberry Pi with its host name. In other words, instead of the IP address that you may not even know, you simply take the hostname, which is much easier to remember. This works both in the browser and via SSH.
Share it:

Raspberry Pi

Post A Comment: