Set Static IP untuk WiFi | Rasp Pi

Raspberry Pi akan gunakan default auto IP dengan Ipv4 Address:
192.168.1.xxx.

Kebanyakan HotSpot dari Smart Phone mempunyai struktur lain:
192.168.43.xxx atau 169.235.1.xxx

Dengan ini, Rasp Pi memang tidak dapat untuk connect pada WiFi network, bila IP Address nya salah, walaupun dalam status mengatakan “Connected”.

SETUP STATIC IP PADA RASP PI MELALUI TERMINAL

Before you begin with the assignment of a private IP address for Raspberry Pi, check whether DHCPCD is already activated using the following command:

sudo service dhcpcd status

In case it’s not, activate DHCPCD as follows:

sudo service dhcpcd start
sudo systemctl enable dhcpcd

Now make sure that the configuration of the file /etc/network/interfaceshas the original status. For this, the ‘iface’ configuration needs to be set at ‘manual’ for the interfaces.

For the editing of the activated DHCPCDs, start by opening the configuration file /etc/dhcpcd.confand running the following command:

sudo nano /etc/dhcpcd.conf

You’ll now carry out the configuration of the static IP address. If your Raspberry Pi is connected to the internet via an Ethernet or network cable, then enter the command ‘interface eth0’; if it takes place over Wi-Fi, then use the ‘interface wlan’ command.

To assign an IP address to Raspberry Pi, use the command ‘static ip_address=’ followed by the desired IPv4 address and the suffix ‘/24’ (an abbreviation of the subnet mak 255.255.255.0). For example, if you want to link a computer with the IPv4 address 192.168.0.4, then you need to use the command ‘static ip_address=192.168.0.4/24’. It goes without saying that the address used here is not yet used anywhere else. As such, it also can’t be located in the address pool of a DHCP server.

You still then need to specify the address of your gateway and domain name server (usually both are the router). Raspberry Pi turns to the gateway address if an IP address to which it wants to send something is outside of the subnet mask (in the example, this would mean outside of the range 192.168.0). In the following command, the IPv4 address 192.168.0.1 is used as an example as both the gateway and DNS server. The complete command looks like this in our example (where a network cable is used for the internet connection):

interface eth0
static ip_address=192.168.0.4/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

The command lines above match the IPv4 addresses that you want to use for your Raspberry Pi, or where your router is assigned. Save the changes with ‘Ctrl + O’ and then press the enter key. Close the configuration file with ‘Ctrl + X’. Restart to adopt the newly assigned static IP address in the network:

sudo reboot

Tinggalkan Jawapan

Masukkan butiran anda dibawah atau klik ikon untuk log masuk akaun:

WordPress.com Logo

Anda sedang menulis komen melalui akaun WordPress.com anda. Log Out /  Tukar )

Google photo

Anda sedang menulis komen melalui akaun Google anda. Log Out /  Tukar )

Twitter picture

Anda sedang menulis komen melalui akaun Twitter anda. Log Out /  Tukar )

Facebook photo

Anda sedang menulis komen melalui akaun Facebook anda. Log Out /  Tukar )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.