Raspberry Pi: assign a fixed IP address - how it works
In a home network, the IP addresses are usually assigned via DHCP. This practical tip shows you how to assign a fixed IP address to your Raspberry Pi.
Assign a fixed IP address to Raspberry Pi
In order for your Raspberry Pi to have a permanent IP address, you have to do the following steps:
- Start the terminal on your Raspberry Pi and execute the command "netstat -r -n".
- Now look for the IP address of your router in the "Gateway" column and make a note of it.
- Now open the network configuration with "sudo nano / etc / network / interfaces".
- Replace the "iface eth0 inet dhcp" line with the following four lines: "iface eth0 inet static", "address 192.168.178.28", "netmask 255.255.255.0" and "gateway 192.168.178.1".
- You can enter your desired IP address under "address". However, this must be in the permitted address space.
- For the address after the point "gateway" you have to enter your gateway address noted in point two.
- Now save the configuration with [CTRL] + [X], [Y] and finally [Enter].
- Finally, you only have to restart the network service with "sudo /etc/init.d/networking restart".