I have a Pi using only the /boot partition on the SD card, with /boot/cmdline.txt set to mount / from a partition on the external USB drive, & I edited /etc/network/interfaces to use a fixed IP address on the LAN. But I've noticed that when I reboot it, it comes up with a DHCP address first, then changes to the fixed IP. What have I done wrong, & how do I fix it?
Most home routers make it easy to reserve an IP address for any device (by MAC address), so running a DHCP client by default shouldn't be a nuisance unless you have a really good reason not to.
I've never connected a keyboard, mouse, or monitor to this Pi --- I just used dd to put the image on the SD card, put that in the Pi, started it up, found it on the LAN (with a DHCP address) and used ssh to do the rest (obviously changing the default password first...). And I'd like to not have to dig out a spare keyboard (& so on) later if it doesn't connect according to the static LAN IP for some reason.
--
I used to be better at logic problems, before I just dumped
them all into TeX and let Knuth pick out the survivors.
-- plorkwort
I set this file up manually so I can ssh in via the static IP
192.168.7.101 and it lets my RPi access the internet via my router, which is on 192.168.7.1
I run a DNS server on my main system which names both the RPi and the router so I can refer to the RPi as 'rpi' and the router as 'hellsgate' from anywhere on my LAN. There's also a file /etc/network/interfaces.dhcp that looks like this:
I don't remember where the second file came from, but it was probably set up automatically last time I did a clean install as part of increasing the SD card size. If thats what happened I'd have renamed the newly set up /etc/network/interfaces file to /etc/network/interfaces.dhcp to preserve it before dropping my copy of interfaces into /etc/network and rebooting the RPi to make it come up with a known static IP.
I do not have a keyboard and monitor on my RPi because I only use it via an SSH login.
--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
Removing it will also remove a package called "raspberrypi-net-mods", which annoyingly claims that file as one of it's configuration files. If you use the "purge" option of apt-get, it will delete your /etc/network/interfaces file!
So, either don't use the purge option, or take a copy of your interfaces file and put it back after removing that package and before rebooting.
I just remembered that if I'm at home, I can correct the contents of files by mounting the SD card (which is just /boot now) & the USB drive into my laptop. So I just have to avoid the temptation to fiddle with certain things from outside the house.
--
We do not debug. Our software does not coddle the weak. Bugs
are good for building character in the user.
--- Klingon Programmer's Guide
as well as some auto wlan0, allow-hotplug wlan0 stuff, & same again for wlan1, which I should delete. I guess those come in the default configuration for people using the USB wifi dongles instead of a cable.
--
Most Americans are too civilized to hang skulls from baskets, having
been headhunters, of course, only as recently as Vietnam.
--- Kinky Friedman
--
New Socialism consists essentially in being seen to have your heart in
the right place whilst your head is in the clouds and your hand is in
someone else's pocket.
I wouldn't worry too much about those wlan entries. You can get rid of them if you like, but they won't do anything unless you plug in a wireless dongle.
I don't know why the Foundation put in both auto eth0 and allow-hotplug eth0, it should really just be one or the other. I use auto where the interface is built-in, like on the Pi B models, and allow-hotplug where it is a removable device like a laptop card or USB adapter.
isn't the auto bit saying 'bring this up on boot'?
formatting link
Well, let?s separate it into pieces, to make it easier to understand /etc/network/interfaces:
"auto interface ? Start the interface(s) at boot. That?s why the lo interface uses this kind of linking configuration."
"allow-hotplug interface ? Start the interface when a "hotplug" event is detected. In the real world, this is used in the same situations as auto but the difference is that it will wait for an event like "being detected by udev hotplug api" or "cable linked"."
--
New Socialism consists essentially in being seen to have your heart in
the right place whilst your head is in the clouds and your hand is in
someone else's pocket.
Aha, I figured out how to disable it without removing the package: edit /etc/dhcpcd.conf (that is a difficult filename to type correctly!) to add these two lines:
nodhcp nodhcp6
Thanks to everyone for the pointers.
--
Unix is a user-friendly operating system. It's just very choosy about
its friends.
Oops, it turns out that doing that hoses the resolver. I could ssh into the pi but it couldn't contact anything else. I also needed to add a name_servers="..." line to /etc/resolvconf.conf and run 'resolvconv -u'.
I saw some stuff on the WWW to that effect, but I wasn't sure it would work on Raspbian, & I've already made a couple of mistakes by trying stuff that works on Ubuntu (e.g., /usr/bin/sensible-editor) without double-checking first!
--
svn ci -m 'come back make, all is forgiven!' build.xml
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.