June 9, 2008
Xen virtual interfaces with more than one IP
I’ve got a load of boxes running Debian etch with Xen 3.0.3 with routed networking (rather than bridged, so I can do iptables and reverse path filtering etc in dom0). Since upgrading from Xen 2.x many moons ago, I’ve not known how to configure one virtual interface to have more than one IP. In the meantime, I’ve ended up doing nonsense like providing a VM with two interfaces just to give it two IPs. However, this interacts really badly with reverse path filtering unless you do a bunch of source-routing rocket science in the domU to send out through the right vif.
So, I looked at the vif-route script and it seems to support iterating through a space-separated list of IPs, but I was totally unable to find any documentation or mailing list posts explaining how to format the IPs within the formerly-Python key/value Xen domain config file syntax. After a while playing with the parser and various levels of quoting, I found that actually, the correct amount of quoting is none at all, and also uncovered a bug in another script which prevents it from working correctly. In the hope that this might help others using Google and trying to achieve the same as me, here is my recipe for configuring Xen vif devices to have multiple IPs (note that I think this might be specific to Xen 3.0.x, as I believe 3.2.x introduces config files in the S-expression format which is what xenstore uses internally):
- Configure your VM using this surprisingly obvious, but somewhat dubious syntax (including a second argument just to prove that yes, it really does work like that):
vif=['ip=1.2.3.4 5.6.7.8, mac=00:16:3e:01:23:45']
When parsed into SXP by xm create, this sets the ip value correctly as a space separated list as the scripts expect:
(device (vif (ip '1.2.3.4 5.6.7.8') (mac 00:16:3e:01:23:45)))
- Fix the bug in /etc/xen/scripts/vif-common.sh:
--- /etc/xen/scripts/vif-common.sh~ 2008-06-09 01:14:23.065065119 +0100
+++ /etc/xen/scripts/vif-common.sh 2008-06-09 01:11:06.599986274 +0100
@@ -103,7 +103,7 @@
if [ "$ip" != "" ]
then
local addr
- for addr in "$ip"
+ for addr in $ip
do
frob_iptable -s "$addr"
done
- Set up multi-homed or aliased interfaces as normal in the domU (depending if you’re a ip or an ifconfig kinda guy).
- Profit!
Calendar
M | T | W | T | F | S | S |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 |
Links
Archives
- April 2024
- February 2024
- March 2023
- November 2022
- May 2022
- February 2022
- June 2021
- January 2021
- August 2019
- October 2018
- July 2017
- May 2010
- October 2009
- August 2009
- July 2009
- March 2009
- January 2009
- July 2008
- June 2008
- April 2008
- May 2007
- January 2007
- December 2006
- June 2006
- April 2006
- March 2006
- November 2005
- October 2005
- September 2005
- August 2005
- July 2005
- May 2005
- April 2005
- March 2005