> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dwe.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Set a Static IP Address on Raspberry Pi

> This guide explains how to configure a static IP address on your Raspberry Pi.

<Note>
  This guide assumes you have sudo access on your Raspberry Pi and are comfortable using the terminal.
</Note>

<Card title="PhoenixNAP Guide" icon="link" href="https://phoenixnap.com/kb/raspberry-pi-static-ip">
  We created this guide based on the one here! Click here if you want more detailed info.
</Card>

## Open a Terminal Window on the Raspberry Pi

If you're connected directly to your Raspberry Pi with a monitor and keyboard, you can open the terminal by clicking on the terminal icon or pressing `Ctrl` + `Alt` + `T`.

If you're connected via SSH, you are already in a terminal session.

<Card title="SSH Instructions" icon="link" href="/dwe-os/guides/ssh-rpi">
  SSH Guide for your Raspberry Pi.
</Card>

## Determine Network Interface and Current IP

<Steps>
  <Step title="List Network Interfaces">
    In the terminal, run the following command to list your network interfaces:

    ```
    ip addr
    ```
  </Step>

  <Step title="Identify Your Interface">
    Look for the interface you are using (e.g., `eth0` for wired connection or `wlan0` for wireless). Note down the interface name.
  </Step>

  <Step title="Find Current IP Address">
    Under the interface, look for the `inet` line to find your current IP address. Note down the IP address, subnet mask, router (gateway), and DNS server.
  </Step>
</Steps>

## Edit the `dhcpcd` Configuration File

<Steps>
  <Step title="Open the Configuration File">
    Use a text editor like `nano` to edit the `dhcpcd.conf` file:

    ```
    sudo nano /etc/dhcpcd.conf
    ```
  </Step>

  <Step title="Add Static IP Configuration">
    Scroll to the end of the file and add the following lines, replacing the placeholders with your actual network details:

    ```
    interface <your_interface_name>
    static ip_address=<desired_static_ip_address>/<subnet_mask>
    static routers=<your_router_ip>
    ```

    <Note>
      **BlueOS Example:**

      ```
      interface eth0
      static ip_address=192.168.2.2/24
      static routers=192.168.2.1
      ```
    </Note>
  </Step>

  <Step title="Save and Exit">
    Press `Ctrl` + `X` to exit, then `Y` to save changes, and `Enter` to confirm the file name.
  </Step>
</Steps>

## Restart the Raspberry Pi

Restart your Raspberry Pi to apply the changes:

```
sudo reboot -h now
```

## Verify the Static IP Configuration

After rebooting, open the terminal on the Raspberry Pi and run:

```
ip addr
```

Confirm that your interface now has the static IP address you configured.

<Note>
  If you are unable to connect to your Raspberry Pi after setting a static IP, ensure that the IP address is within your network's range and does not conflict with other devices.
</Note>
