Changes

Jump to: navigation, search

Virtual Ethernet device

1,682 bytes added, 01:19, 7 September 2009
Common configurations with virtual Ethernet devices: new section : Using a directly routed IPv4 with virtual Ethernet device
=== Simple configuration with virtual Ethernet device ===
 
Assuming you have 192.168.0.0/24 on your LAN, you will learn how to integrate a container in this LAN using veth.
==== Start a CT ====
[host-node]# vzctl start 101
 
==== Add veth device to CT ====
[host-node]# ip route add 192.168.0.101 dev veth101.0
 
 
=== Using a directly routed IPv4 with virtual Ethernet device ===
 
==== Situation ====
Hardware Node (HN/CT0) has 192.168.0.1/24 with router 192.168.0.254.
 
We also know that IPv4 10.0.0.1/32 is directly routed to 192.168.0.1 (this is called a ''fail-over IP'').
 
We want to give this directly routed IPv4 address to a container (CT).
 
==== Start container ====
 
[host-node]# vzctl start 101
 
==== Add veth device to CT ====
 
[host-node]# vzctl set 101 --netif_add eth0 --save
 
This allocates a MAC address and associates it with the host eth0 port.
 
==== Configure device and add route in CT0 ====
 
<pre>
[host-node]# ifconfig veth101.0 0
[host-node]# ip route add 10.0.0.1 dev veth101.0
</pre>
 
Make sure that you have IPv4 forwarding enabled.
<pre>
[host-node]# echo 1 > /proc/sys/net/ipv4/ip_forward
[host-node]# echo 1 > /proc/sys/net/ipv4/conf/eth0/forwarding
[host-node]# echo 1 > /proc/sys/net/ipv4/conf/veth101.0/forwarding
</pre>
You can permanently set this by using <tt>/etc/sysctl.conf</tt>.
 
==== Configure device in CT ====
 
1. Configure IP address
 
2. Add gateway
 
3. Add default route
 
<pre>
[ve-101]# /sbin/ifconfig eth0 10.0.0.1
[ve-101]# /sbin/ip route add 192.168.0.1 dev eth0
[ve-101]# /sbin/ip route default via 192.168.0.1
</pre>
 
In a Debian container, you can configure this permanently by using <tt>/etc/network/interfaces</tt>:
<pre>
auto eth0
iface eth0 inet static
address 10.0.0.1
netmask 255.255.255.255
up /sbin/ip route add 192.168.0.1 dev eth0
up /sbin/ip route add default via 192.168.0.1
</pre>
8
edits

Navigation menu