Skip to content

Commit 439d8c9

Browse files
authored
Merge pull request #17 from chris968/patch-1
Routed and nated networks support
2 parents 38211a5 + aeb5be6 commit 439d8c9

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@ should be a dict containing the following items:
2626
`libvirt_host_networks` is a list of networks to define and start. Each item
2727
should be a dict containing the following items:
2828
- `name` The name of the network.
29-
- `mode` The forwarding mode of the network, currently only `bridge` is
29+
- `mode` The forwarding mode of the network, `bridge`, `route` and `nat` are
3030
supported.
3131
- `bridge` The name of the bridge interface for this network.
32-
33-
`libvirt_host_require_vt`is whether to require that Intel Virtualisation
32+
- `ip` IP address of the virtual bridge, mandatory for `route` and `nat` mode.
33+
- `netmask` Netmask of the virtual bridge, mandatory for `route` and `nat` mode.
34+
- `domain` DNS domain name for `route` and `nat` mode, default to the network
35+
name (optional).
36+
- `dhcp_start` First IP of the DHCP range in `route` or `nat` mode (optional).
37+
- `dhcp_end` Last IP of the DHCP range in `route` or `nat` mode (optional).
38+
39+
`libvirt_host_require_vt` is whether to require that Intel Virtualisation
3440
Technology (VT) is enabled in order to run this role. While this provides
3541
better VM performance, it may not be available in certain environments. The
3642
default value is `true`.
@@ -91,6 +97,14 @@ Example Playbook
9197
- name: br-example
9298
mode: bridge
9399
bridge: br-example
100+
- name: brnat-example
101+
mode: nat
102+
bridge: brnat-example
103+
domain: example.local
104+
ip: 192.168.133.254
105+
netmask: 255.255.255.0
106+
dhcp_start: 192.168.133.100
107+
dhcp_end: 192.168.133.200
94108

95109
Author Information
96110
------------------

templates/network.xml.j2

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,14 @@
22
<name>{{ item.name }}</name>
33
<forward mode='{{ item.mode }}'/>
44
<bridge name='{{ item.bridge }}'/>
5+
{% if item.mode == 'route' or item.mode == 'nat' %}
6+
<domain name='{{ item.domain|default(item.name) }}'/>
7+
<ip address='{{ item.ip }}' netmask='{{ item.netmask }}'>
8+
{% if item.dhcp_start is defined and item.dhcp_end is defined %}
9+
<dhcp>
10+
<range start='{{ item.dhcp_start }}' end='{{ item.dhcp_end }}'/>
11+
</dhcp>
12+
{% endif %}
13+
</ip>
14+
{% endif %}
515
</network>

0 commit comments

Comments
 (0)