- **Epistemic status:** #budding Setting a static IP for a device in [[Linux]] is necessary when building a server for [[Pi-hole]], a static website, backups, etc. If this step is skipped every time you reboot your device, a new IP will be assigned and will result in configuration issues since the IP is used for identifying the service. The first step is to make sure the DHCPCP client is running. You can verify entering the following command: ```bash sudo service dhcpcd status ``` In the case that is **not active**, you can enter these 2 commands: ```bash sudo service dhcpcd start sudo systemctl enable dhcpcd ``` The second step is to edit the `dhcpcd.conf`, but to set it up correctly we need a few pieces of information: 1. **interface:** Defines which network interface you are setting the configuration for. 2. **static ip_address:** The IP address that you want to set your device to (Make sure you leave the /24 at the end). 3. **static routers:** The IP address of your gateway (Most likely the IP address of your router). 4. **static domain_name_servers:** The IP address of your DNS (Most likely the IP address of your router). You can add multiple IP addresses here, separated with a single space. You can get all this information by entering the `ifconfig` command and verifying your router settings. After you get the information, enter the following command, replacing the text editor for the one you desire, such as Nano, Emac, [[Vim]], or [[Vi]]: ```bash sudo vi /etc/dhcpcd.conf ``` You can use the following template to set up your static IP replacing the fields accordingly. ```bash interface eth0 static ip_address=192.168.0.10/24 static routers=192.168.0.1 static domain_name_servers=192.168.0.1 interface wlan0 static ip_address=192.168.0.200/24 static routers=192.168.0.1 static domain_name_servers=192.168.0.1 ``` Save, quit and reboot the system by typing `reboot` command. You should see the same IP address on each reboot. --- ## References - “Dhcpcd - ArchWiki.” Accessed May 10, 2022. <https://wiki.archlinux.org/title/Dhcpcd>. - “Ifconfig - Unix, Linux Command.” Accessed May 10, 2022. <https://www.tutorialspoint.com/unix_commands/ifconfig.htm>.