# [OpenVZ] network

## Theasker

Anybody know how to configure the network for openvz?, I find information to do so and I have no knowledge to the bridge or what he has to do.

thanks in advance

----------

## drescherjm

Using a bridge with openvz is not necessary. In the 5 or so HW nodes I have only 2 of them are using a bridge.

However I can tell you one area you may run into trouble. The default script that initializes the network for gentoo does not work or at least not as expected.

Here is part of my /etc/vz/200.conf file that I have on the machine I am typing from:

```
# CPU fair sheduler parameter

CPUUNITS="1000"

OFFLINE_MANAGEMENT="yes"

VE_ROOT="/vz/root/$VEID"

VE_PRIVATE="/vz/private/$VEID"

OSTEMPLATE="gentoo-20060317-amd64-stage3"

ORIGIN_SAMPLE="vps.basic"

IP_ADDRESS="192.168.1.240"

HOSTNAME="vs_svn"

NAME="vs_svn"
```

----------

## marksteven

Hi,

Kernel module

First of all, check that vznetdev module is loaded:

# lsmod | grep vznetdev

If it is not, load the module:

# modprobe vznetdev

You might want to check /etc/init.d/vz script to make sure the module gets loaded during startup.

Adding IP address to a container

vzctl set <CTID> --ipadd <IP1>[,<IP2>,...] [--save]

Note: This option is incremental, so IP addresses are added to already existing ones.

Example

vzctl set 101 --ipadd 10.0.0.1 --save

After executing this command IP address 10.0.0.1 will be added to container 101 and IP configuration will be saved to a container configuration file.

Removing IP address from a container

vzctl set <CTID> --ipdel <IP1>[,<IP2>,...] [--save]

vzctl set <CTID> --ipdel all [--save]

Example

vzctl set 101 --ipdel 10.0.0.1

After executing this command IP address 10.0.0.1 will be removed from container 101, but IP configuration will not be changed in container config file. And after container reboot IP address 10.0.0.1 will be assigned to this container again. 

Thanks for sharing this information.

----------

## Theasker

 *marksteven wrote:*   

> Hi,
> 
> Kernel module
> 
> First of all, check that vznetdev module is loaded:
> ...

 

```
# modprobe vznetdev 

FATAL: Module vznetdev not found.

# modprobe vznetdev

FATAL: Module vznetdev not found.
```

 *marksteven wrote:*   

> 
> 
> You might want to check /etc/init.d/vz script to make sure the module gets loaded during startup.
> 
> Adding IP address to a container
> ...

 

```
# /etc/init.d/vz start

 * Service vz starting

 failed to load module vzmon                                                      [ !! ]

 * ERROR:  vz failed to start

```

 *marksteven wrote:*   

> 
> 
> vzctl set <CTID> --ipadd <IP1>[,<IP2>,...] [--save]
> 
> Note: This option is incremental, so IP addresses are added to already existing ones.
> ...

 

 *This is the process I followed to install OpenVZ wrote:*   

> # emerge openvz-sources
> 
> boot with the kernel openvz
> 
> echo "sys-cluster/vzctl ~x86" >> /ect/portage/package.keywords
> ...

 

----------

## drescherjm

Do the following and post the output:

```
vzctl enter 101 

ifconfig

route
```

----------

## Theasker

 *# ifconfig wrote:*   

> lo        Link encap:Local Loopback  
> 
>           inet addr:127.0.0.1  Mask:255.0.0.0
> 
>           UP LOOPBACK RUNNING  MTU:16436  Metric:1
> ...

 

 *# route wrote:*   

> Kernel IP routing table
> 
> Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
> 
> 192.168.0.0     *               255.255.255.0   U     0      0        0 venet0
> ...

 

 *# cat /etc/conf.d/net wrote:*   

> dns_servers_venet0="192.168.0.69"
> 
> config_venet0=( "192.168.0.101/24" )
> 
> routes_venet0=( "default via 192.168.0.1" )
> ...

 

----------

## drescherjm

Looks fine.

On the HN (hardware node) edit the /etc/ssh/sshd_config so that the listen address is just the ip address of the host.

Then restart sshd on the HN and guest.

So on my HN

```

datastore3 ~ # grep Listen /etc/ssh/sshd_config

ListenAddress 192.168.1.33

#ListenAddress ::

```

----------

## drescherjm

BTW, here is what I have for my kernel config

```
datastore3 ~ # zgrep VZ /proc/config.gz

CONFIG_VZ_FAIRSCHED=y

# OpenVZ

CONFIG_VZ_GENCALLS=y

CONFIG_VZ_DEV=m

CONFIG_VZ_WDOG=m

CONFIG_VZ_CHECKPOINT=m

CONFIG_VZ_QUOTA=m

CONFIG_VZ_QUOTA_UNLOAD=y

CONFIG_VZ_QUOTA_UGID=y

datastore3 ~ # lsmod | grep vz

vznetdev               24072  4

vzrst                 122728  0

vzcpt                 105592  0

tun                    16452  2 vzrst,vzcpt

vzdquota               43508  2 [permanent]

vzmon                  29520  5 vznetdev,vzrst,vzcpt

vzdev                   7248  3 vznetdev,vzdquota,vzmon

datastore3 ~ # uname -a

Linux datastore3 2.6.27.21-openvz-ext4-new-00011-g36d3faf-dirty #10 SMP Thu Aug 27 04:46:33 EDT 2009 x86_64 Intel(R) Core(TM)2 Quad CPU Q9550 @ 2.83GHz GenuineIntel GNU/Linux

```

----------

## Theasker

 *# nano /etc/ssh/sshd_config wrote:*   

> Port 22
> 
> ...
> 
> #AddressFamily any
> ...

 

```
# /etc/init.d/sshd restart

gentoo-openvz-~x86-2008-11-30 / # ping 192.168.0.101 

PING 192.168.0.101 (192.168.0.101) 56(84) bytes of data.

64 bytes from 192.168.0.101: icmp_seq=1 ttl=64 time=0.209 ms

64 bytes from 192.168.0.101: icmp_seq=2 ttl=64 time=0.136 ms

64 bytes from 192.168.0.101: icmp_seq=3 ttl=64 time=0.031 ms

^C

--- 192.168.0.101 ping statistics ---

3 packets transmitted, 3 received, 0% packet loss, time 1998ms

rtt min/avg/max/mdev = 0.031/0.125/0.209/0.073 ms

gentoo-openvz-~x86-2008-11-30 / # ping 192.168.0.69 

PING 192.168.0.69 (192.168.0.69) 56(84) bytes of data.

^C

--- 192.168.0.69 ping statistics ---

4 packets transmitted, 0 received, 100% packet loss, time 3106ms

gentoo-openvz-~x86-2008-11-30 / # ping 192.168.0.1

PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.

^C

--- 192.168.0.1 ping statistics ---

6 packets transmitted, 0 received, 100% packet loss, time 5011ms

exit

$ ssh root@192.168.0.101

ssh: connect to host 192.168.0.101 port 22: Connection refused
```

----------

## Theasker

```
# cd /usr/src/linux

TheaskerHost linux # zgrep VZ /proc/config.gz 

CONFIG_VZ_FAIRSCHED=y

# OpenVZ

CONFIG_VZ_GENCALLS=y

CONFIG_VZ_DEV=y

CONFIG_VZ_WDOG=y

CONFIG_VZ_CHECKPOINT=y

CONFIG_VZ_QUOTA=m

# CONFIG_VZ_QUOTA_UNLOAD is not set

CONFIG_VZ_QUOTA_UGID=y

# lsmod | grep vz 

# uname -a

Linux TheaskerHost 2.6.27-openvz-briullov.1-r2 #2 SMP Sat Aug 29 09:17:46 CEST 2009 i686 Intel(R) Pentium(R) 4 CPU 3.20GHz GenuineIntel GNU/Linux
```

----------

## drescherjm

I am not sure of this issue. I can definitely ping from the guest:

```
datastore3 ~ # vzctl enter 200

entered into CT 200

vs_ldap2 / # ping 192.168.1.33

PING 192.168.1.33 (192.168.1.33) 56(84) bytes of data.

64 bytes from 192.168.1.33: icmp_seq=1 ttl=64 time=0.020 ms

64 bytes from 192.168.1.33: icmp_seq=2 ttl=64 time=0.025 ms

64 bytes from 192.168.1.33: icmp_seq=3 ttl=64 time=0.026 ms

64 bytes from 192.168.1.33: icmp_seq=4 ttl=64 time=0.024 ms

64 bytes from 192.168.1.33: icmp_seq=5 ttl=64 time=0.008 ms

64 bytes from 192.168.1.33: icmp_seq=6 ttl=64 time=0.009 ms

^C

--- 192.168.1.33 ping statistics ---

6 packets transmitted, 6 received, 0% packet loss, time 5002ms

rtt min/avg/max/mdev = 0.008/0.018/0.026/0.008 ms

vs_ldap2 / #

```

Your /etc/init.d/vz is not starting because it wants to load vz modules. I believe if you define MODULES_DISABLED=yes in your /etc/conf.d/vz that the init script will not try to do this and actually start. I have never tested this on any of my openvz machines however.

Are there any failures in your /proc/user_beancounters?

This would be any line with failcnt > 0

----------

## Theasker

ok, It's disabled

 *cat /etc/conf.d/vz wrote:*   

> ...
> 
> MODULES_DISABLED=yes
> 
> ...

 

Now start the service, but this option does not load any module, I don't know if they will be required to operate the network 

# /etc/init.d/vz start

 * Service vz starting

 * Service vz started

I think I also have misconfigured network Virtual Machine

Host configuratión

 * # cat /etc/conf.d/net wrote:*   

> # Red wireless atheros con madwifi
> 
> modules=( "iwconfig" )
> 
> iwconfig_wlan0="mode ad-hoc"
> ...

 

 *# cat /etc/resolv.conf  wrote:*   

> nameserver 195.235.113.3
> 
> nameserver 194.143.192.22
> 
> 

 

Virtual Machine configuratión

I do not know how to configure the Virtual Machine Network

 *# cat /etc/conf.d/net wrote:*   

> dns_servers_venet0="192.168.0.69" 
> 
> config_venet0=(  "192.168.0.101/32" )
> 
> routes_venet0=(  "default via 192.168.0.1" )
> ...

 

 *# cat /etc/resolv.conf wrote:*   

> # Generated by net-scripts for interface venet0
> 
> nameserver 192.168.0.69
> 
> 

 

 *Quote:*   

> 
> 
> # vzctl enter 101
> 
> entered into VE 101
> ...

 

--- === EDIT === ---

If I shut down and restart the virtual machine, change the file /etc/conf.d/net

 *# cat /etc/conf.d/net wrote:*   

> # This blank configuration will automatically use DHCP for any net.*
> 
> # scripts in /etc/init.d.  To create a more complete configuration,
> 
> # please review /usr/share/doc/openrc/net.example and save your configuration
> ...

 

----------

