mirror of
https://github.com/pi-hole/docs.git
synced 2026-02-14 23:18:30 +00:00
WIP: Get started on static IP addressing guide
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
74
docs/guides/misc/setting-static-ip.md
Normal file
74
docs/guides/misc/setting-static-ip.md
Normal file
@@ -0,0 +1,74 @@
|
||||
[DRAFT]
|
||||
|
||||
When you plug your device into the network, you will be assigned an IP address from the router. For most use cases, this is all that is needed, but for servers it is strongly recommended that the IP address is made static.
|
||||
|
||||
This means ensuring that no matter how many times the device is rebooted / disconnected and reconnected it will _always_ get the same IP address.
|
||||
|
||||
Depending on your operating system / device. There are many ways to achieve this, we will list a few here.
|
||||
|
||||
# Raspbian / Raspberry Pi OS
|
||||
|
||||
First, lets make take some notes about our current network settings with the following command:
|
||||
|
||||
`ip r | grep default`
|
||||
|
||||
This will spit out something along the lines of:
|
||||
|
||||
```
|
||||
default via 192.168.1.254 dev eth0 proto dhcp src 192.168.1.80 metric 202`
|
||||
```
|
||||
|
||||
The first IP address here (`192.168.1.254`) is the IP address of our router. The second one (`192.168.1.80`) is the IP address that the router has assigned our Raspberry pi. Depending on your requirements, you can either choose to keep this IP or change it entirely. Just make sure that the IP address you choose is not already in use.
|
||||
|
||||
We also need to know the DNS server that has been set. to do this run the following command:
|
||||
|
||||
`cat /etc/resolv.conf`
|
||||
|
||||
Which will output something along the lines of:
|
||||
|
||||
```
|
||||
# Generated by resolvconf
|
||||
nameserver 192.168.1.254
|
||||
```
|
||||
|
||||
We are interested in the IP address next to `nameserver`.
|
||||
|
||||
Now that you have the above IP addresses noted down, it's time to modify `dhcpcd.conf` to set it as static. To do so, first run this command:
|
||||
|
||||
`sudo nano /etc/dhcpcd.conf`
|
||||
|
||||
This will bring up a text editor (`nano`) - into which you can enter your desired settings.
|
||||
|
||||
One other thing we will need to know is the interface. If you are plugged into the network via a cable (strongly recommended), then you will want `eth0`, or if you have connected via WiFi, then you will want `wlan0`
|
||||
|
||||
For demonstration purposes, we should now have the following noted down:
|
||||
|
||||
```bash
|
||||
$ROUTER=192.168.1.254
|
||||
$STATIC_IP=192.168.1.80
|
||||
$NAMESERVER=192.168.1.254
|
||||
$INTERFACE=eth0
|
||||
```
|
||||
|
||||
Scroll all the way to the bottom of this file and enter the following lines (replacing `$VARIABLE`s with your own values):
|
||||
|
||||
```bash
|
||||
interface $INTERFACE
|
||||
static ip_address=$STATIC_IP/24
|
||||
static routers=$ROUTER
|
||||
static domain_name_servers=$NAMESERVER
|
||||
```
|
||||
|
||||
To save: press `CTRL` + `X`, then `Y` and then press `ENTER` to confirm.
|
||||
|
||||
Finally, reboot your Raspberry Pi to apply the new settings.
|
||||
|
||||
#
|
||||
|
||||
# All Operating Systems
|
||||
|
||||
Providing you do not wish to use Pi-hole as a DHCP server, you should be able to set a static IP address from the router, however each router will be different. At a high level, the basic idea is usually along the same lines:
|
||||
|
||||
- Head into the router settings - usually by typing in your router's IP, i.e `192.168.0.1`.
|
||||
- Find the LAN DHCP Settings.
|
||||
- Assign desired IP address to the device
|
||||
@@ -46,13 +46,9 @@ The following operating systems are **officially** supported:
|
||||
|
||||
### IP Addressing
|
||||
|
||||
Pi-hole needs a static IP address to properly function (a DHCP reservation is just fine). Users may run into issues because **we currently install `dhcpcd5`, which may conflict with other running network managers** such as `dhclient`, `dhcpcd`, `networkmanager`, and `systemd-networkd`.
|
||||
Pi-hole needs a static IP address to properly function (a DHCP reservation is just fine).
|
||||
|
||||
As part of our install process, **we append some lines to `/etc/dhcpcd.conf` in order to statically assign an IP address**, so take note of this before installing.
|
||||
|
||||
Please be aware of this fact because it [may cause confusion](https://github.com/pi-hole/pi-hole/issues/1713#issue-260746084). This is not the ideal situation for us to be in but, since a significant portion of our users are running Pi-hole on Raspbian - and because Pi-hole's roots began with the Raspberry Pi - it's a problem that is [difficult to get away from](https://github.com/pi-hole/pi-hole/issues/1713#issuecomment-332317532).
|
||||
|
||||
Due to the complexity of different ways of setting an IP address across different systems, it's a slow process and [we need help](https://github.com/pi-hole/pi-hole/issues/629). If you're willing to contribute, please let us know.
|
||||
If you are unsure how to do this, we have prepared a basic guide [here](guides/../../guides/misc/setting-static-ip.md).
|
||||
|
||||
### Ports
|
||||
|
||||
|
||||
@@ -155,6 +155,7 @@ nav:
|
||||
- 'Troubleshooting': guides/vpn/openvpn/troubleshooting.md
|
||||
- 'Misc':
|
||||
- 'Benchmarking': guides/misc/benchmark.md
|
||||
- 'Setting a static IP': guides/misc/setting-static-ip.md
|
||||
- 'Tor & Pi-hole':
|
||||
- 'Overview': guides/misc/tor/overview.md
|
||||
- 'Basic Setup': guides/misc/tor/setup.md
|
||||
|
||||
Reference in New Issue
Block a user