Changes

Jump to: navigation, search

Multiple network interfaces and ARP flux

2,820 bytes added, 10:32, 14 June 2011
The Quick Fix: remove CONFIG_CUSTOMIZED
== Overview ==This page discusses how to setup a HN working with multiple network interfaces on the same physical network [[Hardware Node]] (HN), how this results in ARP Flux, and on the same IP network. Then how to setup multiple VE's to use only one of these interfacesaddress this.
For example, ==The Simple Case==In the simple case you want some of your VE's to always use eth3have multiple network interfaces on the HN, and some to use eth4all with IP addresses in the same subnet. But none Each of your containers also have IP addresses in the VE traffic should use eth0, which is reserved for use by the HN onlysame subnet. This makes sense if you have VE's that may generate or receive a lot of traffic and you You don't want care which interfaces your remote administration of the server over eth0 to degrade or get blocked because of thiscontainers use.
So, no action is required. Everything just works. Setup OpenVZ normally.
 
The only downside is '''ARP flux'''. This describes the usually harmless condition where the network address (layer 3) drifts between multiple hardware addresses (layer 2). While this may cause some confusion to anyone trouble shooting, or generate alarms on network monitoring systems, it doesn't interrupt network traffic.
 
For an example of what this may look like, see the example and tcpdump captures below.
 
==A More Complex Case==
Let's say you have three network interfaces on the HN, all with IP addresses on the same subnet. Each of your containers also have IP addresses on the same subnet. But now you ''do'' care which interface your containers use.
 
For example, you want some of your containers to always use <code>eth3</code>, and some to use <code>eth4</code>. But none of the container traffic should use <code>eth0</code>, which is reserved for use by the HN only. This makes sense if you have containers that may generate or receive a lot of traffic and you don't want your remote administration of the server over <code>eth0</code> to degrade or get blocked because of this.
 
===Example Network Setup===
To make this clear we'll use the following HN configuration. We'll also have another system to act as the client.
{| align="center" borderclass="1wikitable" cellpadding=5
! System !! Interface !! MAC Address !! IP Address
|-
|}
=== HN ARP Flux ===The first issue is fixing the '''ARP flux''' noted above. Any client on the network broadcasting an ARP "who has" message for any of these the HN addresses will receive replies from all three interfaces. This results in IP addresses that float between three MAC addresses, depending on which response a client accepts first.
====Example One - HN ARP Flux====For example, the following is a tcpdump capture from executing <precode>ping -c2 192.168.18.10</precode> from another the client system on the network.
<pre>
</pre>
The ARP "who has" message generated replies from all three MAC addresses on the HN. In this case the client took the MAC address for eth4. The three ICMP messages are then sent to eth4, but all the replies com come from eth0. Normally this behavior isn't a problem, though it may generate some false alarms for a network monitor as it appears someone could be executing a man in the middle attack.
The following output is from executing this command on the HN.
</pre>
====A Simple Fix That May Work====
If all three network interfaces are on different IP networks (such as 10.x.x.x, 172.16.x.x, 192.168.x.x) then executing the following will work:
<codepre>sysctl -w net.ipv4.conf.all.arp_filter=1</codepreHowever, if they are all on the same IP network, which is the case here, then this won't achieve the desired results.
However, if they are all on the same IP network, which is the case here, then the ====A More Effective Solution====The following solution will work. This can be added to your /etc/sysctl.conf file once you've tested it.
<pre>
</pre>
====Example Two - HN ARP Flux Corrected====Now we repeat the ping command, after the arp cache on the client has been cleared.
<pre>
The desired affect has been achieved. Only interface eth0 on the HN responds to the ARP message and the other interfaces are silent.
=== Adding some VE's containers=== Now that the HN is behaving as expected, let's add some VE's to the HN as follows:containers and see what happens.
==== Container network setup====
The case we are addressing is when the containers are on the same subnet as the HN. So we create two new containers and assign the addresses as follows.
{| align="center" borderclass="1wikitable" cellpadding=5! VEID CTID || IP
|-
| 101 || 192.168.18.101
|}
====Example Three - container ARP Flux====From another the client system on the network you should be able to ping bothcontainers. However, looking at the ARP traffic with tcpdump you'll see that once again the physical network address associated with each VE container will be subject to ARP flux, drifting between all three IP link layer addresses over time.
<pre>
</pre>
====The ARP Cache====The reasons for this can be found from executing the following command on the HNto display the ARP cache.
<pre>arp -an</pre>
</pre>
What this shows is that each VE's container IP address is associated with each HN's interface. Therefore each interface will respond to any ARP "who has" query.
====The Cause====
These entries are created by the vzarp function in the vps_functions script, which are called by vps-net_add, vps-net_del and vps-stop. The result of this function in our case is to execute the following commands:
</pre>
In addition, the following ARP messages are sent when VEID CTID 101 is started.
<pre>
What we see here is the result of vzarpipdetect, another function in vps_functions called by vps-net_add. An ARP "who has" message is sent by each interface and answered by the other interfaces.
What we want is to only add the IP addresses of our VE's containers to specific devices, not to all devices. This will prevent the ARP flux problem for our VE'scontainers.
====The Quick Fix====
Unfortunately this involves editing the OpenVZ scripts. The only case we really care about is vps-net_add, as the others execute <code>ip neigh del proxy</code>.
Manually editing the vzarp script is a quick fix, but not advised. Creating your own ''fork'' of OpenVZ is difficult to maintain and may have unintended side affects. Fortunately there is a feature which will allow custom scripts to run during container startup. This approach is also described in [[virtual Ethernet device]]. Create the file /etc/vz/vznet.conf or /etc/vz/vznetcfg. Note that this will only work with a recent version of OpenVZ (vzctl-3.0.14) as the change was introduced in December, 2006. The file name seems to have changed between the two listed here so some trial and error may be required. <pre>#!/bin/bashEXTERNAL_SCRIPT="/usr/lib/vzctl/scripts/vznet-custom"</pre> Finally create the file /usr/lib/vzctl/scripts/vznet-custom and add your custom commands. TODO: Discuss changes contents of script and provide examples. Still need to work on getting this to work. ==Testing Environment==All of the examples have been generated and tested using Debian Etch for the HN and Debian Stable for the containers. VMware Workstation was used to scriptscreate the test networks. The client is the BackTrack live CD from Remote Exploit. If you have different results from other releases of Linux please edit this page.
[[Category:HOWTO]]
[[Category:Networking]]
[[Category:Debian]]

Navigation menu