Network settings for KVM

From ISPWiki

Jump to: navigation, search

When creating a virtual private server, the system creates a virtual network interface and connects it to a network device within the VPS.

The following parameters can be defined for a network device in the virtual server:

  • model of the network card
  • MAC-address

The following parameters can be defined for a virtual network interface:

  • Name of the network interface
  • VPS start/stop scripts
File:Kvmnet-2.png
Module «Network settings for KVM»


Image:T-bullet.gif View a list of network connections
Image:T-new.png Add new configuration
Image:T-edit.png Edit properties
Image:T-delete.png Delete configuration


View a list of network connections

  • Name - name of the configuration that is used in the virtual server configuration file.
  • Priority - priority that is used to select network configurations. If a virtual server has more than one configuration, the one with higher priority will be selected.
  • Network - if set to "auto", the configuration which network corresponds to the primary IP-address of the virtual server will be shown.
  • Network interface name - prefix of the virtual network interface's name. The full name consists of the prefix and virtual server's ID.
  • MAC-address template - template that was used to generate the MAC address. The default value is 52:54:00:_:_:_
  • Model - a model of the network device connected to the virtual server.

Add new configuration

To add a new setting for a virtual server, click the "Add" icon and fill out the form:

The "Basic" tab

File:Kvmnet.edit.jpg
Module «Network settings for KVM»
  • Name - name of the setting that is used in the virtual server configuration file.
  • Interface - prefix of the virtual network interface's name. The full name consists of the prefix and virtual server's ID.
  • MAC-address template - a template that was used to generate the MAC address. The "_" symbol will be changed into a random one. The default value is 52:54:00:_:_:_
  • Network card model - select a model of the network device connected to the virtual server.
  • Network priority - priority that is used to select network configurations. If a virtual server has more than one settings, the one with higher priority will be selected.
  • Network - if the network configuration is set to "auto", the setting which network corresponds to the primary IP-address of the virtual server will be shown.

The "Start/stop scripts" tab

File:Kvmnet.edit.scripts.jpg
Module «Network settings for KVM»
  • Upper field - script that is used to start the network interface.
  • Lower field - script that is executed when trying to stop the interface.

Edit properties

To edit network configuration, locate the one you wish to edit, click the "Edit" icon and modify the settings you want to change.

Delete configuration

To delete network configuration, select it from the list and click the "Delete" icon. Confirm that you want to delete the selected configuration by clicking OK in the following form.

Example

Suppose your server will include virtual servers of two types:

  • VPSs that were assigned addresses from 188.45.77.0/24 should be connected to the network interface eth0
  • VPS that were assigned addresses 10.1.1.1/24 should be connected to the network interface eth1 should have MAC-addresses starting with 10:01

Suppose, the file /etc/network/interfaces looks something like this:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual
auto eth1
iface eth1 inet manual

auto br0
iface br0 inet static
  address 188.45.77.2
  netmask 255.255.255.0
  gateway 188.45.77.1
  bridge_ports eth0

auto br1
iface br1 inet static
  address 10.1.1.2
  netmask 255.255.255.0
  gateway 10.1.1.1
  bridge_ports eth1

Add the following parameters:

external connection

  • network name: Public
  • Interface: tap
  • Template: the default value - 52:54:00:_:_:_
  • Network card model: rtl8139
  • Network priority - 1
  • Network - 0.0.0.0/0
  • Start script:
#!/bin/sh -x
export PATH="${PATH}:/sbin:/usr/sbin"
bridge=br0
brctl addbr br0
tunctl -t $1
ifconfig $1 0.0.0.0 promisc up
brctl addif ${bridge} $1
exit 0
  • Stop script:
#!/bin/sh -x
export PATH="${PATH}:/sbin:/usr/sbin"
ifconfig $1 down
exit 0

Internal connection

  • Network name: Private
  • Interface: tap
  • Template: the default value - 10:01:_:_:_:_
  • Network card model: virtio
  • Network priority - 2
  • Network - 10.1.1.0/24
  • Start script:
#!/bin/sh -x
export PATH="${PATH}:/sbin:/usr/sbin"
bridge=br1
brctl addbr ${bridge}
tunctl -t $1
ifconfig $1 0.0.0.0 promisc up
brctl addif ${bridge} $1
exit 0
  • Stop script:
#!/bin/sh -x
export PATH="${PATH}:/sbin:/usr/sbin"
ifconfig $1 down
exit 0

If IP-address 10.1.1.6 will be assigned to a newly created virtual private server, it will be automatically connected to the internal network.

Was this helpful? Yes | No
Views
Personal tools