|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * virt/node_network/virt-updating-node-network-config.adoc |
| 4 | + |
| 5 | +[id="virt-example-nmstate-IP-management_{context}"] |
| 6 | += Examples: IP management |
| 7 | + |
| 8 | +The following example configuration snippets demonstrate different methods of IP management. |
| 9 | + |
| 10 | +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. |
| 11 | + |
| 12 | +[id="virt-example-nmstate-IP-management-static_{context}"] |
| 13 | +== Static |
| 14 | + |
| 15 | +The following snippet statically configures an IP address on the Ethernet interface: |
| 16 | + |
| 17 | +[source,yaml] |
| 18 | +---- |
| 19 | +... |
| 20 | + interfaces: |
| 21 | + - name: eth1 |
| 22 | + description: static IP on eth1 |
| 23 | + type: ethernet |
| 24 | + state: up |
| 25 | + ipv4: |
| 26 | + address: |
| 27 | + - ip: 192.168.122.250 <1> |
| 28 | + prefix-length: 24 |
| 29 | + enabled: true |
| 30 | +... |
| 31 | +---- |
| 32 | +<1> Replace this value with the static IP address for the interface. |
| 33 | + |
| 34 | +[id="virt-example-nmstate-IP-management-no-ip_{context}"] |
| 35 | +== No IP address |
| 36 | + |
| 37 | +The following snippet ensures that the interface has no IP address: |
| 38 | + |
| 39 | +[source,yaml] |
| 40 | +---- |
| 41 | +... |
| 42 | + interfaces: |
| 43 | + - name: eth1 |
| 44 | + description: No IP on eth1 |
| 45 | + type: ethernet |
| 46 | + state: up |
| 47 | + ipv4: |
| 48 | + enabled: false |
| 49 | +... |
| 50 | +---- |
| 51 | + |
| 52 | +[id="virt-example-nmstate-IP-management-dhcp_{context}"] |
| 53 | +== Dynamic host configuration |
| 54 | + |
| 55 | +The following snippet configures an Ethernet interface that uses a dynamic IP address, gateway address, and DNS: |
| 56 | + |
| 57 | +[source,yaml] |
| 58 | +---- |
| 59 | +... |
| 60 | + interfaces: |
| 61 | + - name: eth1 |
| 62 | + description: DHCP on eth1 |
| 63 | + type: ethernet |
| 64 | + state: up |
| 65 | + ipv4: |
| 66 | + dhcp: true |
| 67 | + enabled: true |
| 68 | +... |
| 69 | +---- |
| 70 | + |
| 71 | +The following snippet configures an Ethernet interface that uses a dynamic IP address but does not use a dynamic gateway address or DNS: |
| 72 | + |
| 73 | +[source,yaml] |
| 74 | +---- |
| 75 | +... |
| 76 | + interfaces: |
| 77 | + - name: eth1 |
| 78 | + description: DHCP without gateway or DNS on eth1 |
| 79 | + type: ethernet |
| 80 | + state: up |
| 81 | + ipv4: |
| 82 | + dhcp: true |
| 83 | + auto-gateway: false |
| 84 | + auto-dns: false |
| 85 | + enabled: true |
| 86 | +... |
| 87 | +---- |
| 88 | + |
| 89 | +[id="virt-example-nmstate-IP-management-dns_{context}"] |
| 90 | +== DNS |
| 91 | + |
| 92 | +The following snippet sets DNS configuration on the host. |
| 93 | + |
| 94 | +[source,yaml] |
| 95 | +---- |
| 96 | +... |
| 97 | + interfaces: |
| 98 | + ... |
| 99 | + dns-resolver: |
| 100 | + config: |
| 101 | + search: |
| 102 | + - example.com |
| 103 | + - example.org |
| 104 | + server: |
| 105 | + - 8.8.8.8 |
| 106 | +... |
| 107 | +---- |
| 108 | + |
| 109 | +[id="virt-example-nmstate-IP-management-static-routing_{context}"] |
| 110 | +== Static routing |
| 111 | + |
| 112 | +The following snippet configures a static route and a static IP on interface `eth1`. |
| 113 | + |
| 114 | +[source,yaml] |
| 115 | +---- |
| 116 | +... |
| 117 | + interfaces: |
| 118 | + - name: eth1 |
| 119 | + description: Static routing on eth1 |
| 120 | + type: ethernet |
| 121 | + state: up |
| 122 | + ipv4: |
| 123 | + address: |
| 124 | + - ip: 192.0.2.251 <1> |
| 125 | + prefix-length: 24 |
| 126 | + enabled: true |
| 127 | + routes: |
| 128 | + config: |
| 129 | + - destination: 198.51.100.0/24 |
| 130 | + metric: 150 |
| 131 | + next-hop-address: 192.0.2.1 <2> |
| 132 | + next-hop-interface: eth1 |
| 133 | + table-id: 254 |
| 134 | +... |
| 135 | +---- |
| 136 | +<1> The static IP address for the Ethernet interface. |
| 137 | +<2> Next hop address for the node traffic. This must be in the same subnet as the IP address set for the Ethernet interface. |
0 commit comments