Open kaspernissen opened 8 years ago
This has been open for nearly a year; any plans to make it a reality? I'm looking for a solution to recovery from a power outage where my dhcp server isn't up yet when the pi boots.
to fix ip address sudo nano /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8) # Include files from /etc/network/interfaces.d: #source-directory /etc/network/interfaces.d allow-hotplug eth0 iface eth0 inet static address 192.168.1.97 network 192.168.1.0 netmask 255.255.255.0 broadcast 192.168.1.255 gateway 192.168.1.1 dns-nameservers 8.8.8.8
ctrl+x and tape y than ENTER don't forget to use your own address, network, broadcast and gateway the gateway address is the address of your internet router, the one you use to get access to modem panel, for network generally the first 3 par (for me 192.168.1.) and add 0, for broadcast same as before but it end with 255, the gateway should already be calculated, for dns-nameservers you can use the same ( it's of google)
Dear @tsouhaieb ,
your fix is working indeed but the dns-nameservers are not copied over to the /etc/resolv.conf
file.
After every reboot I need to add the nameservers to re-establish the network-connection with sudo /etc/resolv.conf
.
Is there a fix already present or perhaps another solution?
best regards
the workaround works but would be great to have a solution with config and without a need to log in to the pi and set this manually. This is useful when using a cluster (k8s) you dont want IP to change. thanks
We no longer actively maintain device-init any longer. HypriotOS 1.7.0 switched to cloud-init. Here is an example to set a static IP address with the user-data cloud-config file. https://github.com/hypriot/flash/blob/master/sample/static.yml
@StefanScherer
We no longer actively maintain device-init any longer. HypriotOS 1.7.0 switched to cloud-init. Here is an example to set a static IP address with the user-data cloud-config file. https://github.com/hypriot/flash/blob/master/sample/static.yml
Yep and using that exact example file (with IP addresses edited to suit) and flash (2.7.0) to burn Hypriot 1.12.3 to SD does not result in a static IP being set when RPi booted with SD inserted. The RPi still is running on auto IP via DHCP. Any hacks to set a static IP have knock on problems.
Command line that uses your suggestion @StefanScherer but does not result in static IP working:
flash --userdata static.yaml hypriotos-rpi-v1.12.3.img.zip
Noting /etc/dhcpcd.conf is definitely set according to --userdata.
Noting /etc/resolv.conf is auto populated with name servers, pull from gateway via DHCP server on gateway, and so name resolution is provided.
However IP is provided DHCP and not static.
Noting also that if static IP hack is used to "fix" the problem with --userdata method failing, /etc/resolv.conf will end up empty of references to nameservers and you therefore don't get name resolution. For example, using Hypriot 1.12.3 with static IP hacks and no name services means you cannot pull docker images since you cannot find the hub on the internet.
The missing nameservers in /etc/resolv.conf is because all suggested hacks, for getting around --userdata method failing, involve disabling cloud-init. Understanding also that a warning is provided in /etc/resolv.conf to the effect manual entry of nameservers is verboten, because the contents of /etc/resolv.conf will be automatically replaced.
Something clearly needs to be done to allow static IP being set that doesn't require hacks and takes account of the problems with setting of static IP, including disabling of cloud-init, and therefore of dropping access to nameservers. Copying junk into /etc/dhcpcd.conf does not appear to help nor does the other hacks on offer.
Reopen of issue from flash-repo: Issue 25
Option for setting a static ip for eth0 would be a great addition. Thanks!