KitchM
Posts: 30
Joined: Fri Jul 12, 2019 5:52 pm

Disable DHCP

Fri Aug 23, 2019 4:06 pm

How can I disable DHCP on Raspbian 9 and just use a static Eth0 address?

User avatar
rpdom
Posts: 15030
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Disable DHCP

Fri Aug 23, 2019 4:22 pm

Edit /etc/dhcpcd.conf to set a static address for the interface. There are examples in the file.

KitchM
Posts: 30
Joined: Fri Jul 12, 2019 5:52 pm

Re: Disable DHCP

Fri Aug 23, 2019 5:18 pm

Thanks, I'll try that again. It didn't work the first time. Somewhere else was the idea to uninstall DHCP.

Andyroo
Posts: 4231
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Disable DHCP

Fri Aug 23, 2019 6:40 pm

Strange though it can be picky if you miss the subnet range off.

The last one I set up was:
######################################
# Added 20th June - matches EE Router
interface eth0
static ip_address=192.168.1.10/24
static routers=192.168.1.254
static domain_name_servers=192.168.1.2
######################################

The note over matching the router is that I got the EE router to let me change the address on its control screen for a change :lol: :cry: :roll:

I just add this at the start of the file and leave everything else alone. Note my network is IPv4 only.
Need Pi spray - these things are breeding in my house...

User avatar
DougieLawson
Posts: 35834
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Disable DHCP

Fri Aug 23, 2019 7:31 pm

You can encourage dhcpcd to completely ignore interfaces then Linux will generate a 169.254.xxx.yyy address for an interface that is UP but doesn't get a DHCP DISCOVERY/OFFER/REQUEST/ACK.

If you add

Code: Select all

denyinterfaces eth0
denyinterfaces wlan0
then it really is disabled.

If you set static addresses with DHCPCD you don't need to supply a router address, just leave that one out or set it to the same address as you've set for the interface.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Return to “Beginners”