Open rbartoli opened 4 years ago
I figured it out. Basically since dhcp was deactivated by #247 I tried to reactivate it and use the example to set the static IP but this led to multiple different issues and multiple appearing IP addresses in the network.
I managed then to set the static IP address with cloud init following this guide: https://clientarea.ramnode.com/knowledgebase/4180/Static-IP-Configuration-Cloud.html Using the debian example works. I think this was the intended way for the PR but didn't get documented or mentioned.
That's awesome @dennym that you found a solution.
Do you want to share it with a small PR to https://github.com/hypriot/flash/blob/master/sample/static.yml to show the correct configuration? Or if it's useful for more people add it to the FAQ https://github.com/hypriot/blog/blob/master/content/faq.md 🤗
Thanks!
@dennym Amazing! Thanks for letting us know and If you could even just share your configuration file, that will be great!
Unfortunately there is no script. I manually added the configuration mention in the link to each node. But I am sure you can utilize the write_files
part where you did the dhcp config to set the cloudinit configuration.
@StefanScherer I feel like my solution is quite hacky. After just having the cloud init setting set and disabling dhcp again I got plenty of dns issues. Either I can't resolve domains on the nodes (so no ping at all to any external domain) or I can't connect to the nodes via their network name pi@NAME.local
. I think deactivating dhcp introduces way more mandatory configurations on the nodes.
I'm glad this has been brought up (see also #366 ). Apparently there are various ways to set up static ip adresses. Using the dhcpcd daemon is recommended since Raspbian Jessie, but is deactivated in hypriot by default (as @rbartoli pointed out).
Would be great if we came up with some best practice here.
@rbartoli try this:
write to file network-config
version: 1
config:
- type: physical
name: eth0
subnets:
- type: static
address: 172.16.1.21/24
gateway: 172.16.1.1
dns_nameservers:
- 172.16.1.1
- 8.8.8.8
dns_search:
- clmaster01
and use it like this:
$ flash -u user-data.yml -F network-config hypriotos.img.zip
There is some time past but I remember that this worked for me when I setup my dev rpi cluster at home.
Let me please know if it works for you.
This works for me:
flash -F network-config hypriotos-rpi-v1.12.3.img
Example for network-config:
version: 2
ethernets:
eth0:
addresses:
- 192.168.1.100/255.255.255.0
Notes:
network-config
To load user-data, meta-data and network-config, Hypriot is using NoCloud as datasource. Read more about this in the cloud-init documentation. Most importantly, there are different ways to define network configurations and using a network-config.yaml file requires you to not use the top network key.
Behind the scenes it is actually pretty simple. Look at the following files after flashing and mounting the sdcard:
HypriotOS/
you can find the meta-data, user-data and network-config files. Hypriot has default files for these, but you can load different files with the flash tool and the corresponding flags. You can also change these files manually, of course, but before booting.root/var/lib/cloud/seed/nocloud-net/
you can find links to these files from the root filesystem. Cloud-init is using these files to configure all sorts of stuff on first boot, for instance root/etc/network/interfaces.d/50-cloud-init.cfg
for network interfaces.Unfortunately, the flashing tool has no specific flag for importing network-config file. That's why we need to use -F as a general way to import files (and that's why the naming is important).
One last note: If you want to alter the network configurations after first boot, you will need to restart cloud-init one way or the other. This could work:
cloud-init clean
reboot
Am I right, that applying just the config for eth0 (as seen above) will remove the docker0 interface and the network bridge, so that accessing docker services via network isn't working any longer? Did somebody come up with a network-config that keeps that setup in place?
I did flash v1.12.1 after editing
/boot/user-data
with the following content:However the static ip configuration seems to have no effect. The RPI boots properly, I can log into the system, however the ip address of the box is not 192.168.0.5.
I did re-flash the same SD card multiple times and manually checked
/etc/dhcpcd.conf
and it contains the expected content.So I did try to use the same above configuration on v1.12.0, flashed it on the same SD and it worked as expected.
I'm happy to provide any info/log if requested.