1) Log into your Pi and switch to the root user:
sudo su
2) Run ifconfig and look at the output. You are interested in the inetaddr, Bcast and Mask of your adapter. You will see your interface as WLAN0 or ETH0. Note down the inetaddr, Bcast and Mask.
ifconfig
3) Obtain the route information of your Pi and note down the Gateway and Destination addresses:
route -n
4) Edit the Network configuration on the Pi.
nano /etc/network/interfaces
You want to change the settings appropriate to your network adapter. If you are using WiFi then change the wlan0 section. If you are using a wired Ethernet connector then change the eth0 section.
4a) Change the DHCP setting to static:
For eth0:
iface eth0 inet manual changes to iface eth0 inet static
For wlan0:
iface wlan0 inet manual changes to iface wlan0 inet static
4b) Add the following configuration below the line you just changed. Change the red text to the information you captured above.
address INETADDR
netmask MASK
network DESTINATION
broadcast BCAST
gateway GATEWAY
5) Save your file (ctrl+o, enter)
6) Reboot the Pi. The IP address is now fixed at boot.
No comments:
Post a comment