User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Static IP address templates for dhcpcd.conf

Sat May 12, 2018 12:15 am

Killertechno wrote:
Tue Apr 17, 2018 3:02 pm
About templates.... (a bit offtopic), is there a way to keep dynamic and static IP at same time?
I need dynamic to be used in dhcp network while active static IP as default for maintenance.
See my second post with "fallback twopi". That should do what you want; it only uses the profile with the static allocations if it can't find a DHCP server.

jag466379
Posts: 2
Joined: Tue Nov 21, 2017 3:23 pm

Re: Static IP address templates for dhcpcd.conf

Thu May 24, 2018 10:39 am

Similar question to killertechno, I need dhcp to do it's usual thing and have static ip address(es) on different subnet(s) all at the same time.
So the Pi Ethernet is permanently controlling machines using the static addresses/subnets but the router/internet can come and go if and when required. In these situations WiFi is not often available.
This used to be easy (before Jessie/Stretch) but now I can't work it out.

dynamicdave
Posts: 2
Joined: Sun Jan 27, 2019 1:39 pm

Re: Static IP address templates for dhcpcd.conf

Sun Jan 27, 2019 1:50 pm

Is there a way/method to assign a fixed IP address according to the name of the WiFi network that the RPi connects to ??

For example, my home domain is 192.168.1.1 (etc..) and I would like the Pi to get IP address 192.168.1.200
But at my daugher's home (she has the same domain) I would like to Pi to get address 192.168.1.60

PS:
I really like the "arping" facility and intend to use it with the Raspberry Pies I use with my students at the IoT Club at school.

DirkS
Posts: 9876
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Static IP address templates for dhcpcd.conf

Sun Jan 27, 2019 4:24 pm

dynamicdave wrote:
Sun Jan 27, 2019 1:50 pm
Is there a way/method to assign a fixed IP address according to the name of the WiFi network that the RPi connects to ??

For example, my home domain is 192.168.1.1 (etc..) and I would like the Pi to get IP address 192.168.1.200
But at my daugher's home (she has the same domain) I would like to Pi to get address 192.168.1.60
There's an 'ssid' option in dhcpcd.conf (see https://www.daemon-systems.org/man/dhcpcd.conf.5.html)
See e.g. https://www.raspberrypi.org/forums/view ... 1#p1242033 for an example

dynamicdave
Posts: 2
Joined: Sun Jan 27, 2019 1:39 pm

Re: Static IP address templates for dhcpcd.conf

Mon Jan 28, 2019 8:48 am

Thanks @DirkS - I think that will sort out my needs.

WillBerriss
Posts: 8
Joined: Tue Jan 06, 2015 4:34 pm

Re: Static IP address templates for dhcpcd.conf

Sat Mar 02, 2019 3:45 pm

Did anyone work out how to see the search domain in /etc/dhcpcd.conf?

I tried a guess of the following:

Code: Select all

static domain_search=blah.net

but this did not work, all I get is this:

Code: Select all

# Generated by resolvconf
domain blah.net
nameserver 10.0.0.1
nameserver 10.0.0.2

All I want it this local box to have the same resolv.conf as the one it dishes out to my other machines via dhcpd.conf, i.e. I want its resolv.conf to look like this:

Code: Select all

# Generated by resolvconf
domain blah.net
search blah.net other.net
nameserver 10.0.0.1
nameserver 10.0.0.2
Anyone know how to achieve this with dhcpc?

Thanks in advance.

WillBerriss
Posts: 8
Joined: Tue Jan 06, 2015 4:34 pm

Re: Static IP address templates for dhcpcd.conf

Sat Mar 02, 2019 4:12 pm

I cheated and edited /etc/resolvconf and put in this line:

Code: Select all

search_domains="blah.net other.net"
then I ran resolvconf -u twice then resolvconf -v which said:

Code: Select all

SEARCH='blah.net other.net'
and then cat /etc/resolv.conf said:

Code: Select all

# Generated by resolvconf
domain blah.net
search blah.net other.net
nameserver 10.0.0.1
nameserver 10.0.0.2

WillBerriss
Posts: 8
Joined: Tue Jan 06, 2015 4:34 pm

Re: Static IP address templates for dhcpcd.conf

Mon Mar 04, 2019 8:59 pm

Actually the following DOES work in /etc/dhcpcd.conf (I stupidly used a comma to separate them at first and it doesn't like that)

Code: Select all

static domain_search=blah.net foobar.net

Return to “Raspbian”