mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-07 00:48:01 +01:00
138 lines
3.1 KiB
Plaintext
138 lines
3.1 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * virt/node_network/virt-updating-node-network-config.adoc
|
|
|
|
[id="virt-example-nmstate-IP-management_{context}"]
|
|
= Examples: IP management
|
|
|
|
The following example configuration snippets demonstrate different methods of IP management.
|
|
|
|
These examples use the `ethernet` interface type to simplify the example while showing the related context in the policy configuration. These IP management examples can be used with the other interface types.
|
|
|
|
[id="virt-example-nmstate-IP-management-static_{context}"]
|
|
== Static
|
|
|
|
The following snippet statically configures an IP address on the Ethernet interface:
|
|
|
|
[source,yaml]
|
|
----
|
|
...
|
|
interfaces:
|
|
- name: eth1
|
|
description: static IP on eth1
|
|
type: ethernet
|
|
state: up
|
|
ipv4:
|
|
address:
|
|
- ip: 192.168.122.250 <1>
|
|
prefix-length: 24
|
|
enabled: true
|
|
...
|
|
----
|
|
<1> Replace this value with the static IP address for the interface.
|
|
|
|
[id="virt-example-nmstate-IP-management-no-ip_{context}"]
|
|
== No IP address
|
|
|
|
The following snippet ensures that the interface has no IP address:
|
|
|
|
[source,yaml]
|
|
----
|
|
...
|
|
interfaces:
|
|
- name: eth1
|
|
description: No IP on eth1
|
|
type: ethernet
|
|
state: up
|
|
ipv4:
|
|
enabled: false
|
|
...
|
|
----
|
|
|
|
[id="virt-example-nmstate-IP-management-dhcp_{context}"]
|
|
== Dynamic host configuration
|
|
|
|
The following snippet configures an Ethernet interface that uses a dynamic IP address, gateway address, and DNS:
|
|
|
|
[source,yaml]
|
|
----
|
|
...
|
|
interfaces:
|
|
- name: eth1
|
|
description: DHCP on eth1
|
|
type: ethernet
|
|
state: up
|
|
ipv4:
|
|
dhcp: true
|
|
enabled: true
|
|
...
|
|
----
|
|
|
|
The following snippet configures an Ethernet interface that uses a dynamic IP address but does not use a dynamic gateway address or DNS:
|
|
|
|
[source,yaml]
|
|
----
|
|
...
|
|
interfaces:
|
|
- name: eth1
|
|
description: DHCP without gateway or DNS on eth1
|
|
type: ethernet
|
|
state: up
|
|
ipv4:
|
|
dhcp: true
|
|
auto-gateway: false
|
|
auto-dns: false
|
|
enabled: true
|
|
...
|
|
----
|
|
|
|
[id="virt-example-nmstate-IP-management-dns_{context}"]
|
|
== DNS
|
|
|
|
The following snippet sets DNS configuration on the host.
|
|
|
|
[source,yaml]
|
|
----
|
|
...
|
|
interfaces:
|
|
...
|
|
dns-resolver:
|
|
config:
|
|
search:
|
|
- example.com
|
|
- example.org
|
|
server:
|
|
- 8.8.8.8
|
|
...
|
|
----
|
|
|
|
[id="virt-example-nmstate-IP-management-static-routing_{context}"]
|
|
== Static routing
|
|
|
|
The following snippet configures a static route and a static IP on interface `eth1`.
|
|
|
|
[source,yaml]
|
|
----
|
|
...
|
|
interfaces:
|
|
- name: eth1
|
|
description: Static routing on eth1
|
|
type: ethernet
|
|
state: up
|
|
ipv4:
|
|
address:
|
|
- ip: 192.0.2.251 <1>
|
|
prefix-length: 24
|
|
enabled: true
|
|
routes:
|
|
config:
|
|
- destination: 198.51.100.0/24
|
|
metric: 150
|
|
next-hop-address: 192.0.2.1 <2>
|
|
next-hop-interface: eth1
|
|
table-id: 254
|
|
...
|
|
----
|
|
<1> The static IP address for the Ethernet interface.
|
|
<2> Next hop address for the node traffic. This must be in the same subnet as the IP address set for the Ethernet interface.
|