Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for static IP address on FCOS #30

Merged
merged 4 commits into from
Feb 4, 2020

Conversation

adriannemora
Copy link
Contributor

This is a simple example of how to assign a static IP address to an interface on FCOS.

Comment on lines 23 to 38
contents: inline
[connection]
id=Uplink
type=802-3-ethernet
autoconnect=true
interface-name=eth0
match-device=interface-name:eth0
uuid=<insert UUID>
[ethernet]
mac-address=<insert MAC address>
[ipv4]
method=manual
addresses=192.0.2.1/24
gateway=192.0.2.255
dns=192.0.2.53
dns-search=example.com
Copy link
Member

@miabbott miabbott Jan 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be tweaked slightly so that inline: is a child of contents:. And the mode should be set to 0644, I think.

      contents: 
        inline: |
          [connection]
          id=Uplink
          type=802-3-ethernet
          autoconnect=true
          interface-name=eth0
          match-device=interface-name:eth0
          uuid=<insert UUID>
          [ethernet]
          mac-address=<insert MAC address>
          [ipv4]
          method=manual
          addresses=192.0.2.1/24
          gateway=192.0.2.255
          dns=192.0.2.53
          dns-search=example.com

@miabbott
Copy link
Member

I was able to reduce the keyfile down to this:

[connection]
type=ethernet
interface-name=eth0

[ethernet]
mac-address=52:54:00:0d:5c:06

[ipv4]
method=manual
addresses=192.168.124.120/24
gateway=192.168.124.1
dns=192.168.124.1;1.1.1.1;8.8.8.8
dns-search=redhat.com

However, the interface doesn't come up correctly on first boot. The eth0 interface was getting a DHCP address during the first boot.

I had to use nmcli connection down eth0 and nmcli connection up eth0 for the static IP to take effect.

The following snippet shows how to assign the following to eth0:

* static IP range: `192.0.2.1/24`
* gateway: `192.0.2.255`
Copy link
Member

@miabbott miabbott Jan 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addresses that end in 255 are typically broadcast addresses and wouldn't be used as a gateway. I'd suggest changing the value of the static IP to 192.0.2.10/24 and the gateway to 192.0.2.1


The following snippet shows how to assign the following to eth0:

* static IP range: `192.0.2.1/24`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's only a single IP being assigned here; just drop range


* static IP: `192.0.2.10/24`
* gateway: `192.0.2.1`
* DNS: `92.168.124.1;1.1.1.1;8.8.8.8`
Copy link
Member

@miabbott miabbott Feb 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, the first DNS address should be 192.168.124.1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doh! sorry for the copy-pasta error!

----
NOTE: During the initramfs portion of the boot process, dracut will attempt to grab a DHCP address. When it times out, Ignition will take over and write the above configuration into the filesystem.

If the interface does not come up correctly on first boot, issue the following commands to force the static IP to take effect:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's link to the issue in the tracker for additional visibility - coreos/fedora-coreos-tracker#358

----
NOTE: During the initramfs portion of the boot process, dracut will attempt to grab a DHCP address. When it times out, Ignition will take over and write the above configuration into the filesystem.

If the interface does not come up correctly on first boot, issue the following commands to force the static IP to take effect:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, if users haven't setup a user/password in their Ignition config, they won't be able to login via the console to perform the nmcli commands. May be worth mentioning that rebooting the host is another workaround, if they only have SSH keys setup.

Copy link
Member

@miabbott miabbott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor fixups but not worth blocking on

@miabbott
Copy link
Member

miabbott commented Feb 4, 2020

@mike-nguyen Do you have some cycles to review this and/or test out using keyfiles?

@mike-nguyen
Copy link
Member

I'll take a look

mode: 0600
overwrite: true
contents:
inline:
Copy link
Member

@mike-nguyen mike-nguyen Feb 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be inline: | . The pipe is important. I got an error when I didn't use it.

@mike-nguyen
Copy link
Member

Besides the missing pipe in the comment above, I was able to get static networking to work on a network without DHCP using libvirt.

@miabbott
Copy link
Member

miabbott commented Feb 4, 2020

OK, I'm going to merge this and fix the pipe issue in a quick follow-up.

Thanks @adriannemora for the content!

@miabbott miabbott merged commit 2f62807 into coreos:master Feb 4, 2020
@miabbott
Copy link
Member

miabbott commented Feb 4, 2020

Follow-up in #40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants