1. Make a copy of the DHCP configuration file
Always make a copy of system files that you are editing. If your changes don't work the way you expect, you can always roll back to the safe, stable, starting state you began at. This allows you to try again without creating a number of inter-dependant changes.
sudo cp /etc/dhcpcd.conf /etc/dhcpcd.conf.save
2. Find the current IP address of your device
On unix devices (Macs, Raspberry pis, etc.) you can check your current IP with
3. Find the IP address of your router and your Domain Name Server
To find the router's address:
ip r | grep default.
To find the Domain Name Server's address:
grep "nameserver" /etc/resolv.conf
These are typically the same address for a home network.
Why add /24? Check out this discussion on subnet masks
4. Edit the DHCP configuration file
At the end of the file add a block where each of the variables are replaced with the values we previously found:
interface wlan0 static ip_address=<device_ip>/24 static routers=<router_ip> static domain_name_servers=<domain_name_server_ip>
This sets a static IP for the wireless lan, or
wlan0 interface on your device. If you want to also set the ethernet interface, add the exact same block again, but change
And you're done!
If it didn't work out, you can always revert your changes by running:
sudo cp /etc/dhcpcd.conf.save /etc/dhcpcd.conf