mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 07:05:28 +00:00
ccff335f83
network: static route support for <network> This patch adds the <route> subelement of <network> to define a static route. the address and prefix (or netmask) attribute identify the destination network, and the gateway attribute specifies the next hop address (which must be directly reachable from the containing <network>) which is to receive the packets destined for "address/(prefix|netmask)". These attributes are translated into an "ip route add" command that is executed when the network is started. The command used is of the following form: ip route add <address>/<prefix> via <gateway> \ dev <virbr-bridge> proto static metric <metric> Tests are done to validate that the input data are correct. For example, for a static route ip definition, the address must be a network address and not a host address. Additional checks are added to ensure that the specified gateway is directly reachable via this network (i.e. that the gateway IP address is in the same subnet as one of the IP's defined for the network). prefix='0' is supported for both family='ipv4' address='0.0.0.0' netmask='0.0.0.0' or prefix='0', and for family='ipv6' address='::', prefix=0', although care should be taken to not override a desired system default route. Anytime an attempt is made to define a static route which *exactly* duplicates an existing static route (for example, address=::, prefix=0, metric=1), the following error message will be sent to syslog: RTNETLINK answers: File exists This can be overridden by decreasing the metric value for the route that should be preferred, or increasing the metric for the route that shouldn't be preferred (and is thus in place only in anticipation that the preferred route may be removed in the future). Caution should be used when manipulating route metrics, especially for a default route. Note: The use of the command-line interface should be replaced by direct use of libnl so that error conditions can be handled better. But, that is being left as an exercise for another day. Signed-off-by: Gene Czarcinski <gene@czarc.net> Signed-off-by: Laine Stump <laine@laine.org>
27 lines
1.2 KiB
XML
27 lines
1.2 KiB
XML
<network>
|
|
<name>local</name>
|
|
<uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
|
|
<forward dev='eth1' mode='route'>
|
|
<interface dev='eth1'/>
|
|
</forward>
|
|
<bridge name='virbr1' stp='on' delay='0' />
|
|
<mac address='12:34:56:78:9a:bc'/>
|
|
<ip address='192.168.122.1' netmask='255.255.255.0'>
|
|
<dhcp>
|
|
<host mac='00:16:3e:77:e2:ed' name='a.example.com' ip='192.168.122.10' />
|
|
<host mac='00:16:3e:3e:a9:1a' name='b.example.com' ip='192.168.122.11' />
|
|
</dhcp>
|
|
</ip>
|
|
<ip family='ipv6' address='2001:db8:ac10:fd01::1' prefix='64'>
|
|
<dhcp>
|
|
<host id='0:4:7e:7d:f0:7d:a8:bc:c5:d2:13:32:11:ed:16:ea:84:63' ip='2001:db8:ac10:fd01::1:20' />
|
|
<host name='paul' ip='2001:db8:ac10:fd01::1:21' />
|
|
<host id='0:3:0:1:0:16:3e:11:22:33' name='peter.xyz' ip='2001:db8:ac10:fd01::1:22' />
|
|
<host id='0:3:0:1:0:16:3e:44:55:33' ip='2001:db8:ac10:fd01::1:23' />
|
|
<host id='0:1:0:1:18:aa:62:fe:0:16:3e:44:55:66' name='badbob' ip='2001:db8:ac10:fd01::1:24' />
|
|
</dhcp>
|
|
</ip>
|
|
<route address='192.168.222.0' netmask='255.255.255.0' gateway='192.168.122.10'/>
|
|
<route family='ipv6' address='2001:db8:ac10:fc00::' prefix='64' gateway='2001:db8:ac10:fd01::1:24'/>
|
|
</network>
|