millercb
Posts: 10
Joined: Sun Aug 13, 2017 3:40 pm

Static networking and Stretch

Fri Aug 18, 2017 4:31 pm

So this is a two part question, the second of which involved the update to Raspbian Stretch.

1. I have used the cmdline.txt option ip=xxx.xxx.xxx.xxx for a while now to set a static IP on several Pis. It works just fine on my Pi B, Pi 2, and Pi 3, which are all connected via Ethernet. I have a Pi Zero W that I am trying to set up over wireless. I put the wpa_supplicant.conf in the boot partition to get it to copy over, and that works no problem, but the Pi gets an IP address from the DHCP server. Any idea why the cmdline.txt option doesn't work for Wi-Fi? Once I set up a static IP for the wlan0 interface in /etc/network/interfaces it works. Which brings me to my second question.

2. On Stretch, the /etc/network/interfaces file doesn't have the normal interface options (auto wlan0 inet manual, etc. whatever else is in there). This is where I normally set my static IP for my wireless connection. Has this changed somehow? If so, where do I set my static IP now?

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

Re: Static networking and Stretch

Fri Aug 18, 2017 6:52 pm

millercb wrote:
Fri Aug 18, 2017 4:31 pm
2. On Stretch, the /etc/network/interfaces file doesn't have the normal interface options (auto wlan0 inet manual, etc. whatever else is in there). This is where I normally set my static IP for my wireless connection. Has this changed somehow? If so, where do I set my static IP now?
/etc/dhcpcd.conf
This was a change in the RPF Raspbian Jessie images (so it has been around for a while)
Google for 'rasberry pi dhcpcd.conf' to get more info

millercb
Posts: 10
Joined: Sun Aug 13, 2017 3:40 pm

Re: Static networking and Stretch

Sat Aug 19, 2017 4:34 pm

I completely forgot about using DHCPCD. I haven't messed with my pi for a while, and since the cmdline.txt option works with ethernet, which is how I usually connect my Pis, I haven't manually set up a static ip recently. However, I set my static IP in /etc/dhcpcd.conf using the following lines added to the end:

interface wlan0
static ip_address=192.168.0.50/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

The IP correctly sets and I am able to access the Pi, but whenever I try to run apt-get update or even ping a domain, I get:

Temporary failure in name resolution

I can't figure out what the problem is. Anyone have any ideas? I have confirmed if I remove the lines that I added to dhcpcd.conf and go back to dynamic IP, my internet connection works fine, the issue is only when I have the static IP set.

Does anyone know why the cmdline.txt ip setting doesn't work with wireless even though it does with ethernet?

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

Re: Static networking and Stretch

Sat Aug 19, 2017 5:00 pm

Try adding Google DNS to the DNS:

Code: Select all

static domain_name_servers=192.168.0.1 8.8.8.8

millercb
Posts: 10
Joined: Sun Aug 13, 2017 3:40 pm

Re: Static networking and Stretch

Tue Aug 22, 2017 9:22 pm

DirkS wrote:
Sat Aug 19, 2017 5:00 pm
Try adding Google DNS to the DNS:

Code: Select all

static domain_name_servers=192.168.0.1 8.8.8.8
That works, but as it turns out the problem was with my router. I am temporarily using a modem/router combo from the cable company, and it does not work as a DNS by default, so you can't set 192.168.0.1 as your DNS server. I changed the setting to allow it to act as a DNS relay, and it is all working now. Still not sure why the cmdline.txt ip option doesn't work with wlan0 though. It is a much easier way to set up static IP, even though it does give 2 IP addresses to the Pi (it still receives one dynamically from the router as well, but I don't have too much on my local network so it doesn't really bother me as long as I can still access it with the static IP).

RichHaynes
Posts: 45
Joined: Sat Jul 16, 2016 12:23 pm
Location: Stoke-On-Trent

Re: Static networking and Stretch

Fri Aug 25, 2017 6:14 pm

millercb wrote:I have used the cmdline.txt option ip=xxx.xxx.xxx.xxx for a while now to set a static IP on several Pis

It works but I dont think the ip parameter was designed in the way you are using it:
This parameter tells the kernel how to configure IP addresses of devices and also how to set up the IP routing table. It was originally called `nfsaddrs', but now the boot-time IP configuration works independently of NFS, so it was renamed to `ip' and the old name remained as an alias for compatibility reasons. https://www.mjmwired.net/kernel/Documen ... oot.txt#81

It was designed to make sure the computer had some form of IP address so that you can NFS mount the root filesystem. Granted, it has the effect of giving the ethernet device an IP address and achieves your aims but maybe thats why its limited only to the ethernet device. I may be off the mark but that was my understanding of the ip parameter.

I would always use the packages provided by the installed OS to configure the network devices rather than relying on the kernel.
Main Computer: RPi3
BOINC Server: RPi2
Torrent Box: RPi2 + 2TB WD Green HDD via USB Dock
Web + Email Server: RPi2
Home Automation Server: RPi2 + Edimax EW-7811Un
Decomissioned: 2 x RPi Model B

Return to “Raspbian”