Connecting my RasPi to my home LAN, was quite easy. Although, the no. of ways I could connect them together are many, I decided to go the old-school way. Simply connect the Ethernet port of my Router and RasPi , via a straight through cable and get started. My router had already been assigned an IP address, i.e. 192.168.137.1
The next thing I had to do was configure the eth0 interface on my RasPi and assign it a static IP.
These are the steps I followed:
- Open the network interfaces file:
sudo vi /etc/network/interfaces
- In there, replaced the following lines:
auto eth0
iface eth0 inet dhcp
with this:
auto eth0
iface eth0 inet static
address 192.168.137.2
netmask 255.255.255.0
gateway 192.168.137.1
nameserver 192.168.137.1
- Then opened resolv.conf file:
sudo vi /etc/resolv.conf
- In the file, removed all lines and typed in only this line:
nameserver 192.168.137.1
Where, 193.168.137.1 is my gateway, which would help me to connect my RasPi on LAN, with internet.
Save the file and exit the file editor. - Now in terminal, restart the network interfaces:
sudo networking restart
- Then ping my gateway:
ping 192.168.137.1
If it pings, then, ethernet interface is ready to use, else you should reboot RasPi and retry pinging again.