2022年10月8日 星期六

[rapi, ip] How to setup a static ip for the Raspberry Pi

How to setup a static ip for the Raspberry Pi

井民全, jing, mqjing@gmail.com


1. Quick

vi /etc/dhcpcd.conf

interface wlan0

static routers=192.168.1.1

static domain_name_servers=8.8.8.8

static ip_address=192.168.1.200/24

ifdown wlan0 && ifup wlan0

2. Procedure

Step 1: Check your router ip and the device

Command

ip r


Step 2: Setup static ip

If you want to setup a static ip as 192.168.1.200, edit the dhcpcd.conf.

File: /etc/dhcpcd.conf

interface wlan0

static routers=192.168.1.1

static domain_name_servers=8.8.8.8

static ip_address=192.168.1.200/24

ifdown wlan0 && ifup wlan0

3. Verification

Scan the network.

Command

sudo arp-scan -I ens33 --localnet

Result

You can find the raspberry Pi ip was assigned to 192.168.1.200. Where 192.168.1.108 is my another Pi.


4. Reference

  1. https://www.tomshardware.com/how-to/static-ip-raspberry-pi


5. Further Information

  1. https://www.makeuseof.com/raspberry-pi-set-static-ip/