formatnetwork.html.in 11.6 KB
Newer Older
1 2 3 4
<html>
  <body>
    <h1>Network XML format</h1>

5 6 7
    <ul id="toc">
    </ul>

D
Daniel P. Berrange 已提交
8 9 10 11 12 13
    <p>
      This page provides an introduction to the network XML format. For background
      information on the concepts referred to here, consult the <a href="archnetwork.html">network driver architecture</a>
      page.
    </p>

14
    <h2><a name="elements">Element and attribute overview</a></h2>
D
Daniel P. Berrange 已提交
15 16 17 18

    <p>
      The root element required for all virtual networks is
      named <code>network</code> and has no attributes.
19
      The network XML format is available <span class="since">since 0.3.0</span>
D
Daniel P. Berrange 已提交
20 21
    </p>

22
    <h3><a name="elementsMetadata">General metadata</a></h3>
D
Daniel P. Berrange 已提交
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

    <p>
      The first elements provide basic metadata about the virtual
      network.
    </p>

    <pre>
      &lt;network&gt;
        &lt;name&gt;default&lt;/name&gt;
        &lt;uuid&gt;3e3fce45-4f53-4fa7-bb32-11f34168b82b&lt;/uuid&gt;
        ...</pre>

    <dl>
      <dt><code>name</code></dt>
      <dd>The content of the <code>name</code> element provides
M
Matthew Booth 已提交
38 39 40 41 42
        a short name for the virtual network. This name should
        consist only of alpha-numeric characters and is required
        to be unique within the scope of a single host. It is
        used to form the filename for storing the persistent
        configuration file. <span class="since">Since 0.3.0</span></dd>
D
Daniel P. Berrange 已提交
43 44
      <dt><code>uuid</code></dt>
      <dd>The content of the <code>uuid</code> element provides
M
Matthew Booth 已提交
45 46 47 48
        a globally unique identifier for the virtual network.
        The format must be RFC 4122 compliant, eg <code>3e3fce45-4f53-4fa7-bb32-11f34168b82b</code>.
        If omitted when defining/creating a new network, a random
        UUID is generated. <span class="since">Since 0.3.0</span></dd>
D
Daniel P. Berrange 已提交
49 50
    </dl>

51
    <h3><a name="elementsConnect">Connectivity</a></h3>
D
Daniel P. Berrange 已提交
52 53 54 55 56 57 58 59

    <p>
      The next set of elements control how a virtual network is
      provided connectivity to the physical LAN (if at all).
    </p>

    <pre>
        ...
60
        &lt;bridge name="virbr0" stp="on" delay="5"/&gt;
61
        &lt;domain name="example"/&gt;
M
Matthew Booth 已提交
62 63
        &lt;forward mode="nat" dev="eth0"/&gt;
        ...</pre>
D
Daniel P. Berrange 已提交
64 65 66 67

    <dl>
      <dt><code>bridge</code></dt>
      <dd>The <code>name</code> attribute on the <code>bridge</code> element
M
Matthew Booth 已提交
68 69 70 71 72 73 74
        defines the name of a bridge device which will be used to construct
        the virtual network. The virtual machines will be connected to this
        bridge device allowing them to talk to each other. The bridge device
        may also be connected to the LAN. It is recommended that bridge
        device names started with the prefix <code>vir</code>, but the name
        <code>virbr0</code> is reserved for the "default" virtual network.
        This element should always be provided when defining a new network.
75 76 77
        Attribute <code>stp</code> specifies if Spanning Tree Protocol is
        'on' or 'off' (default is 'on'). Attribute <code>delay</code> sets
        the bridge's forward delay value in seconds (default is 0).
M
Matthew Booth 已提交
78
        <span class="since">Since 0.3.0</span>
D
Daniel P. Berrange 已提交
79
      </dd>
80 81 82 83 84 85
      <dt><code>domain</code></dt>
      <dd>
        The <code>name</code> attribute on the <code>domain</code> element
        defines the DNS domain of the DHCP server. This element is optional.
        <span class="since">Since 0.4.5</span>
      </dd>
D
Daniel P. Berrange 已提交
86 87
      <dt><code>forward</code></dt>
      <dd>Inclusion of the <code>forward</code> element indicates that
88 89 90 91 92 93 94
        the virtual network is to be connected to the physical
        LAN. the <code>mode</code> attribute determines the method of
        forwarding; possible selections are 'nat' and 'route'. If mode
        is not specified, NAT forwarding will be used for
        connectivity.  If a network has any IPv6 addresses defined,
        even if <code>mode</code> is given as 'nat', the IPv6 traffic
        will be forwarded using routing, since IPv6 has no concept of NAT.
M
Matthew Booth 已提交
95 96 97 98 99 100 101
        Firewall rules will allow forwarding to any other network device whether
        ethernet, wireless, dialup, or VPN. If the <code>dev</code> attribute
        is set, the firewall rules will restrict forwarding to the named
        device only. If the <code>mode</code> attribute is set to <code>route</code>
        then the traffic will not have NAT applied. This presumes that the
        local LAN router has suitable routing table entries to return traffic
        to this host. <span class="since">Since 0.3.0; 'mode' attribute since
102
        0.4.2</span></dd>
D
Daniel P. Berrange 已提交
103 104
    </dl>

105
    <h3><a name="elementsAddress">Addressing</a></h3>
D
Daniel P. Berrange 已提交
106 107 108 109 110 111 112 113

    <p>
      The final set of elements define the IPv4 address range available,
      and optionally enable DHCP sevices.
    </p>

    <pre>
        ...
M
Matthew Booth 已提交
114 115 116 117 118 119 120
        &lt;ip address="192.168.122.1" netmask="255.255.255.0"&gt;
          &lt;dhcp&gt;
            &lt;range start="192.168.122.100" end="192.168.122.254" /&gt;
            &lt;host mac="00:16:3e:77:e2:ed" name="foo.example.com" ip="192.168.122.10" /&gt;
            &lt;host mac="00:16:3e:3e:a9:1a" name="bar.example.com" ip="192.168.122.11" /&gt;
          &lt;/dhcp&gt;
        &lt;/ip&gt;
D
Daniel P. Berrange 已提交
121 122 123 124 125
      &lt;/network&gt;</pre>

    <dl>
      <dt><code>ip</code></dt>
      <dd>The <code>address</code> attribute defines an IPv4 address in
126 127 128
        dotted-decimal format, or an IPv6 address in standard
        colon-separated hexadecimal format, that will be configured on
        the bridge
M
Matthew Booth 已提交
129
        device associated with the virtual network. To the guests this
130
        address will be their default route. For IPv4 addresses, the <code>netmask</code>
M
Matthew Booth 已提交
131
        attribute defines the significant bits of the network address,
132 133 134 135 136 137 138 139 140 141 142
        again specified in dotted-decimal format.  For IPv6 addresses,
        and as an alternate method for IPv4 addresses, you can specify
        the significant bits of the network address with the <code>prefix</code>
        attribute, which is an integer (for example, <code>netmask='255.255.255.0'</code>
        could also be given as <code>prefix='24'</code>. The <code>family</code>
        attribute is used to specify the type of address - 'ipv4' or 'ipv6'; if no
        <code>family</code> is given, 'ipv4' is assumed. A network can have more than
        one of each family of address defined, but only a single address can have a
        <code>dhcp</code> or <code>tftp</code> element. <span class="since">Since 0.3.0;
        IPv6, multiple addresses on a single network, <code>family</code>, and
        <code>prefix</code> since 0.8.7</span>
143
      </dd><dt><code>tftp</code></dt><dd>Immediately within
M
Matthew Booth 已提交
144 145 146
        the <code>ip</code> element there is an optional <code>tftp</code>
        element. The presence of this element and of its attribute
        <code>root</code> enables TFTP services.  The attribute specifies
147 148 149
        the path to the root directory served via TFTP. <code>tftp</code> is not
        supported for IPv6 addresses, can only be specified on a single IPv4 address
        per network.
M
Matthew Booth 已提交
150
        <span class="since">Since 0.7.1</span>
151
      </dd><dt><code>dhcp</code></dt><dd>Also within the <code>ip</code> element there is an
M
Matthew Booth 已提交
152 153
        optional <code>dhcp</code> element. The presence of this element
        enables DHCP services on the virtual network. It will further
154 155 156
        contain one or more <code>range</code> elements. The
        <code>dhcp</code> element is not supported for IPv6, and
        is only supported on a single IP address per network for IPv4.
M
Matthew Booth 已提交
157
        <span class="since">Since 0.3.0</span>
D
Daniel P. Berrange 已提交
158 159 160
      </dd>
      <dt><code>range</code></dt>
      <dd>The <code>start</code> and <code>end</code> attributes on the
M
Matthew Booth 已提交
161 162 163 164
        <code>range</code> element specify the boundaries of a pool of
        IPv4 addresses to be provided to DHCP clients. These two addresses
        must lie within the scope of the network defined on the parent
        <code>ip</code> element.  <span class="since">Since 0.3.0</span>
D
Daniel P. Berrange 已提交
165
      </dd>
166 167
      <dt><code>host</code></dt>
      <dd>Within the <code>dhcp</code> element there may be zero or more
M
Matthew Booth 已提交
168
        <code>host</code> elements; these specify hosts which will be given
169 170
        names and predefined IP addresses by the built-in DHCP server. Any
        such element must specify the MAC address of the host to be assigned
M
Matthew Booth 已提交
171
        a given name (via the <code>mac</code> attribute), the IP to be
172
        assigned to that host (via the <code>ip</code> attribute), and the
M
Matthew Booth 已提交
173
        name to be given that host by the DHCP server (via the
174
        <code>name</code> attribute).  <span class="since">Since 0.4.5</span>
175
      </dd><dt><code>bootp</code></dt><dd>The optional <code>bootp</code>
176 177 178 179 180 181 182 183 184 185
        element specifies BOOTP options to be provided by the DHCP server.
        Two attributes are supported: <code>file</code> is mandatory and
        gives the file to be used for the boot image; <code>server</code> is
        optional and gives the address of the TFTP server from which the boot
        image will be fetched.  <code>server</code> defaults to the same host
        that runs the DHCP server, as is the case when the <code>tftp</code>
        element is used.  The BOOTP options currently have to be the same
        for all address ranges and statically assigned addresses.<span
        class="since">Since 0.7.1 (<code>server</code> since 0.7.3).</span>
      </dd>
D
Daniel P. Berrange 已提交
186
    </dl>
187

188
    <h2><a name="examples">Example configuration</a></h2>
189

190
    <h3><a name="examplesNAT">NAT based network</a></h3>
191

D
Daniel P. Berrange 已提交
192 193 194 195 196 197 198 199 200 201
    <p>
      This example is the so called "default" virtual network. It is
      provided and enabled out-of-the-box for all libvirt installations.
      This is a configuration that allows guest OS to get outbound
      connectivity regardless of whether the host uses ethernet, wireless,
      dialup, or VPN networking without requiring any specific admin
      configuration. In the absence of host networking, it at least allows
      guests to talk directly to each other.
    </p>

202 203
    <pre>
      &lt;network&gt;
M
Matthew Booth 已提交
204 205 206 207 208 209 210 211
        &lt;name&gt;default&lt;/name&gt;
        &lt;bridge name="virbr0" /&gt;
        &lt;forward mode="nat"/&gt;
        &lt;ip address="192.168.122.1" netmask="255.255.255.0"&gt;
          &lt;dhcp&gt;
            &lt;range start="192.168.122.2" end="192.168.122.254" /&gt;
          &lt;/dhcp&gt;
        &lt;/ip&gt;
212 213
      &lt;/network&gt;</pre>

214
    <h3><a name="examplesRoute">Routed network config</a></h3>
215

D
Daniel P. Berrange 已提交
216 217 218 219 220 221 222 223 224
    <p>
      This is a variant on the default network which routes traffic
      from the virtual network to the LAN without applying any NAT.
      It requires that the IP address range be pre-configured in the
      routing tables of the router on the host network. This example
      further specifies that guest traffic may only go out via the
      <code>eth1</code> host network device.
    </p>

225 226
    <pre>
      &lt;network&gt;
M
Matthew Booth 已提交
227 228 229 230 231 232 233 234
        &lt;name&gt;local&lt;/name&gt;
        &lt;bridge name="virbr1" /&gt;
        &lt;forward mode="route" dev="eth1"/&gt;
        &lt;ip address="192.168.122.1" netmask="255.255.255.0"&gt;
          &lt;dhcp&gt;
            &lt;range start="192.168.122.2" end="192.168.122.254" /&gt;
          &lt;/dhcp&gt;
        &lt;/ip&gt;
235 236
      &lt;/network&gt;</pre>

237
    <h3><a name="examplesPrivate">Isolated network config</a></h3>
238

D
Daniel P. Berrange 已提交
239 240 241 242 243 244 245 246
    <p>
      This variant provides a completely isolated private network
      for guests. The guests can talk to each other, and the host
      OS, but cannot reach any other machines on the LAN, due to
      the omission of the <code>forward</code> element in the XML
      description.
    </p>

247 248
    <pre>
      &lt;network&gt;
M
Matthew Booth 已提交
249 250 251 252 253 254 255
        &lt;name&gt;private&lt;/name&gt;
        &lt;bridge name="virbr2" /&gt;
        &lt;ip address="192.168.152.1" netmask="255.255.255.0"&gt;
          &lt;dhcp&gt;
            &lt;range start="192.168.152.2" end="192.168.152.254" /&gt;
          &lt;/dhcp&gt;
        &lt;/ip&gt;
256 257 258 259
      &lt;/network&gt;</pre>

  </body>
</html>