Raspberrypi : Step-by-Step Static IP Configuration
Working with Raspberry PI (RPI) is fun. If you do not want to directly plug your monitor and keyboard always to your RPI, then you need to configure Static IP on the RPI. Typically in home environment, you will connect your RPI to your router and then need to control the RPI from your PC using SSH. In a router with DHCP enabled, you need to have static IP for your RPI so that IP will not be changed even router is restarted. Following instructions will show how to set up your RPI with static IP.
Requirement:
RPI is loaded with Raspbian and complete the initial setup.
Monitor and Keyboard connected to RPI
Configuration Steps (Single Network)
Open network configuration file using following command
sudo nano /etc/network/interfaces
Update network configuration file as below.
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.123.101
netmask 255.255.255.0
gateway 192.168.123.254
Save the file by pressing "CTRL+O" and exit editor by "CTRL+X"
Then restart the RPI in order to reflect these changes using following command
sudo reboot
Configuration Steps (Multiple Networks)
If you have multiple network connections like Ethernet and Wifi, then static configurations should be in the last part of the network configuration file as shown below. In your static IP configuration remember to add "one tab space" for the config items of the eth0 as shown below.
auto lo
iface lo inet loopback
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
auto eth0
iface eth0 inet static
address 192.168.123.101
netmask 255.255.255.0
gateway 192.168.123.254
NOTE
You can configure your router to assign same IP by adding a rule in your router configurations by using the MAC address of the RPI.
Requirement:
RPI is loaded with Raspbian and complete the initial setup.
Monitor and Keyboard connected to RPI
Configuration Steps (Single Network)
Open network configuration file using following command
sudo nano /etc/network/interfaces
Update network configuration file as below.
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.123.101
netmask 255.255.255.0
gateway 192.168.123.254
Save the file by pressing "CTRL+O" and exit editor by "CTRL+X"
Then restart the RPI in order to reflect these changes using following command
sudo reboot
Configuration Steps (Multiple Networks)
If you have multiple network connections like Ethernet and Wifi, then static configurations should be in the last part of the network configuration file as shown below. In your static IP configuration remember to add "one tab space" for the config items of the eth0 as shown below.
auto lo
iface lo inet loopback
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
auto eth0
iface eth0 inet static
address 192.168.123.101
netmask 255.255.255.0
gateway 192.168.123.254
NOTE
You can configure your router to assign same IP by adding a rule in your router configurations by using the MAC address of the RPI.
Comments
Post a Comment