Easy set static IP address on your Raspberry Pi


Do you want to connect to your Raspberry Pi from other machines with SSH? Here is how to do it secure ssh connection between windows and raspbian. But then it is nice to have static IP address setting on it. Static IP means that the address is the same every time you power up your Pi machine.
If you are new in IP addressing dont worry. Learn more starting from Wkipedia maybe.
You can also search the web with: ‘IP addressing’ or ‘IP address classes’. And then:

  1. Check your local network addressing
    • If you have a machine with Linux working in this network try:ifconfig
    • ifconfig

    • If you have a machine with Windows working in this network launch console (cmd.exe) and type:ipconfig
    • ipconfig
      netmask, Subnet Mask – is the subnet mask shows which bits of the address are machine or subnet.
      inet, IP Address – this is the machine IP address.
      Default Gateway – this is the IP address of your gateway.

  2. Chooseing IP address for Pi machine
    • 192.168.1.0 – bad choice – this is subnet address
    • 192.168.1.1 – bad choice – this is gateway IP address
    • 192.168.1.255 – bad choice – this is so called broadcast IP address
    • 192.168.1.120 – bad choice – it is other machine address in local network
    • 192.168.1.111 – bad choice – it is other machine address in local network
    • So we can choose IP address starting from 192.168.1.2 up to 192.168.1.254 excluding 111 i 120 (are used). Lets set: 192.168.1.225
    • Remember that every IP address can be used only once. Lets check it:ping 192.168.1.225 Destination host is unreachable – that means the address 192.168.1.225 is now free and we can use it.
    • ping_225

  3. Edit configuration file on your Raspberry Pi
    • Type: sudo nano /etc/dhcpcd.conf
    • If your Raspberry should have static IP address in WiFi network append to file:
      interface wlan0
      static ip_address=192.168.1.225/24
      static routers=192.168.1.1
      static domain_name_servers=192.168.1.1
    • If your Raspberry should have static IP address in cable network append to file:
      interface eth0
      static ip_address=192.168.1.225/24
      static routers=192.168.1.1
      static domain_name_servers=192.168.1.1
    • You can also add both if you need.

    • Press ‘ctrl+x’ to exit the nano editor and then press ‘y’ to save changes.
    • edit_dhcpcd.conf

  4. Restart Raspberry Pi
    • Type sudo reboot
    • After restart check if everything is ok.ifconfig
    • ifconfig_225

And finished. Your Raspberry Pi has static IP address !!

Tagged , , . Bookmark the permalink.

Comments are closed.