Give Raspberry Pi a Static IP Address

Setup a static IP addres on the SD-Card

The /etc/network/interfaces file is a core network interface card configuration file on debian. The RPIPLC Raspberry Pi board is standard configured with a static IP address: 192.168.1.44.

Manually configure a static IP address for the Raspberry Pi board

On the SD_card list the network interface we currently have available.

cat /media/username/<sd-card-name>/etc/network/interfaces

root@rpiplc:~# cat /media/username/13d368bf-6dbf-4751-8ba1-88bed06bef77/etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0 
iface eth0 inet static
address 192.168.1.44
gateway 192.168.1.1
netmask 255.255.255.0
dns-nameservers 195.238.2.22 195.238.2.21

First of all we need to grab some information from our network
 

$ ifconfig
eth0      Link encap:Ethernet  HWaddr b8:27:eb:f4:0c:35  
          inet addr:192.168.1.11  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:489 errors:0 dropped:0 overruns:0 frame:0
          TX packets:434 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:43540 (42.5 KiB)  TX bytes:45655 (44.5 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

inet addr – 192.168.1.11 (Computer Current IP Address)
Bcast –  192.168.1.255 (The Broadcast IP Range)
Mask –  255.255.255.0 (Subnet Mask Address)

$ netstat -nr
Kernel IP routing table

Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth0
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0

Gateway Address – 192.168.1.1
Destination Address – 192.168.1.0

To see your DNS server address type following command as shell prompt.

$ cat /etc/resolv.conf
# Generated by resolvconf
domain lan
nameserver 192.168.1.1
nameserver 195.238.2.22
nameserver 195.238.2.21

Editing Network Configuration

We now need to plug this information into the SD-Card Raspberry Pi network configuration file using a text editor.
And give the Raspberry Pi a Static IP Address, for example: 44. I use vim as text editor.

$ sudo vim /media/username/13d368bf-6dbf-4751-8ba1-88bed06bef77/etc/network/interfaces

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.44
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
dns-nameservers 195.238.2.22 195.238.2.21

Save and Exit.

RPIPLC first boot >


 

Add new comment