VLANs in Virtuozzo konfigurieren

Aus Thomas-Krenn-Wiki
Zur Navigation springen Zur Suche springen
Hinweis: Bitte beachten Sie, dass dieser Artikel / diese Kategorie sich entweder auf ältere Software/Hardware Komponenten bezieht oder aus sonstigen Gründen nicht mehr gewartet wird.
Diese Seite wird nicht mehr aktualisiert und ist rein zu Referenzzwecken noch hier im Archiv abrufbar.

Dieser Artikel beschreibt die Nutzung von VLANs für VEs unter Virtuozzo 3 SP1 für Linux. Der Zugriff auf das VLAN wird im Beispiel mehreren VEs ermöglicht (Konfiguration mit veth). Im gezeigten Beispiel ist das Basissystem ein CentOS 4 x86_64. Das VLAN wird im Beispiel am Netzwerk-Device eth2 erstellt (bei einem Thomas Krenn Linux HA Cluster dürfen eth0 und eth1 nicht für VLANs verwendet werden). Es wird ein VLAN mit der VLAN ID 50 genutzt.

Wichtig: am Netzwerkport des Switches muss VLAN Trunking aktiviert werden, damit die Informationen zum VLAN vom Switch an den Server weitergereicht werden.

VLAN Device am Hardware Node konfigurieren

Hinweis: Falls es sich beim Virtuozzo 3 SP1 System um einen Thomas Krenn Linux HA Cluster handelt, sind die folgenden Schritte auf beiden Nodes durchzuführen.

Grundsätzlich ist es möglich im laufenden Betrieb mittels vconfig add eth2 <VLAN-ID> ein VLAN zu konfigurieren. Allerdings ist diese Konfiguration nicht permanent und wäre nach einem Reboot verloren. Daher wird das VLAN mittels folgender Konfigurationsdatei erstellt (der Name der Konfigurationsdatei beinhaltet die VLAN ID):

[root@sr2500test-node1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth2.50
DEVICE=eth2.50
ONBOOT=yes
TYPE=Ethernet
VLAN=yes
[root@sr2500test-node1 ~]# 

In diesem Fall ist eth2 das physikalische Device am Host. Durch die Konfiguration in der Datei ifcfg-eth2.50 wird das Device beim Booten des Servers automatisch aktiviert. Jetzt direkt nach dem Erstellen der Konfigurationsdatei muss das Device allerdings manuell mittels ifup eth2.50 aktiviert werden:

[root@sr2500test-node1 ~]# ifup eth2.50
Added VLAN with VID == 50 to IF -:eth2:-
[root@sr2500test-node1 ~]# cat /proc/net/vlan/config
VLAN Dev name	 | VLAN ID
Name-Type: VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD
eth2.50        | 50  | eth2
[root@sr2500test-node1 ~]# cat /proc/net/vlan/eth2.50
eth2.50  VID: 50	 REORDER_HDR: 1  dev->priv_flags: 21
         total frames received            0
          total bytes received            0
      Broadcast/Multicast Rcvd            0

      total frames transmitted            0
       total bytes transmitted            0
            total headroom inc            0
           total encap on xmit            0
Device: eth2
INGRESS priority mappings: 0:0  1:0  2:0  3:0  4:0  5:0  6:0 7:0
EGRESSS priority Mappings: 
[root@sr2500test-node1 ~]# ifconfig eth2
eth2      Link encap:Ethernet  HWaddr 00:15:17:16:A1:92  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Base address:0x2000 Memory:b8f20000-b8f40000 

[root@sr2500test-node1 ~]# ifconfig eth2.50
eth2.50   Link encap:Ethernet  HWaddr 00:15:17:16:A1:92  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

[root@sr2500test-node1 ~]# 

Anmerkung: Eine Konfigurationsdatei ifcfg-eth2 für das "Haupt-Interface" ist nicht erforderlich, eth2 selbst wird durch ifup eth2.50 automatisch mit hochgebracht.

Netzwerk-Bridge und veth Device konfigurieren

Hinweis: Diese Schritte sind auch bei einem Thomas Krenn Linux HA Cluster nur am aktiven Node durchzuführen.

Die weitere Konfiguration erfolgt gleich wie sie auch bei normalen veth Devices geschieht (siehe dazu auch Netzwerk des Clusters konfigurieren#Konfiguration mit veth).

Konfiguration der Netzwerk-Bridge

[root@sr2500test-node1 ~]# vznetcfg br new bridgeVlan50 networkVlan50
[root@sr2500test-node1 ~]# vznetcfg br attach networkVlan50 eth2.50
[root@sr2500test-node1 ~]# vznetcfg br list
bridge name     bridge id               STP enabled     vnetwork id
bridgeVlan50    8000.00151716a192       no              networkVlan50
[root@sr2500test-node1 ~]# vznetcfg br show networkVlan50
    iface name      VE eth name     iface mac           VE eth mac          bridge
0:
    eth2.50         N/A             00:15:17:16:a1:92   N/A                 bridgeVlan50
[root@sr2500test-node1 ~]# 

Konfiguration des veth Device

Das betroffene VE ist derzeit noch ohne Netzwerk-Konnektivität:

[root@sr2500test-node1 ~]# vzlist 103
      VEID      NPROC STATUS    IP_ADDR         HOSTNAME                        
       103         11 running                   centos4                         
[root@sr2500test-node1 ~]# 

Nun wird die Konfiguration durchgeführt (beachten Sie dabei zuvor die Hinweise in Virtuozzo CentOS VE mit veth Fehler: sysfs class device: Invalid argument falls es sich um ein CentOS/RHEL basierendes VE handelt):

[root@sr2500test-node1 ~]# vzctl set 103 --netif_add eth0 --save
Configure veth devices: veth103.0 
Saved parameters for VE 103
[root@sr2500test-node1 ~]# vzctl set 103 --ifname eth0 --network networkVlan50 --ipadd 10.17.0.10/255.255.255.0 --gw 10.17.0.1 --save
Configure veth devices:  
Configure bridged network...
Shutting down interface eth0:  [  OK  ]
Shutting down interface venet0:  [  OK  ]
Shutting down loopback interface:  [  OK  ]
Setting network parameters:  [  OK  ]
Bringing up loopback interface:  [  OK  ]
Bringing up interface eth0:  [  OK  ]
Bringing up interface venet0:  [  OK  ]
Saved parameters for VE 103
[root@sr2500test-node1 ~]# vzlist 103
      VEID      NPROC STATUS    IP_ADDR         HOSTNAME                        
       103         11 running   10.17.0.10      centos4                         
[root@sr2500test-node1 ~]# vzctl enter 103
entered into VE 103
-bash-3.00# ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:18:51:8F:66:52  
          inet addr:10.17.0.10  Bcast:10.17.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:336 (336.0 b)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

venet0    Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:127.0.0.1  P-t-P:127.0.0.1  Bcast:0.0.0.0  Mask:255.255.255.255
          UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

-bash-3.00# 

Überprüfen der Konfiguration

[root@sr2500test-node1 ~]# vznetcfg br show networkVlan50
    iface name      VE eth name     iface mac           VE eth mac          bridge
0:
    eth2.50         N/A             00:15:17:16:a1:92   N/A                 bridgeVlan50
103:
    veth103.0       eth0            00:18:51:29:96:1B   00:18:51:8F:66:52   bridgeVlan50
[root@sr2500test-node1 ~]# vznetcfg if list
iface           iface configuration                         addr list
bridgeVlan50    bridge/networkVlan50/no                     
eth2.50         vlan/networkVlan50/eth2/50                  
eth0            nic//00:0e:0c:ea:92:a0                      192.168.1.151/24
eth1            nic//00:0e:0c:ea:92:a1                      192.168.255.1/24
eth2            nic//00:15:17:16:a1:92                      
eth3            nic//00:15:17:16:a1:93                      
[root@sr2500test-node1 ~]# 

Weblink

http://wiki.openvz.org/VLAN

Das könnte Sie auch interessieren

Erstellung eines SLES10 Repositories zum Verwenden des SLES10 Templates in Virtuozzo 3
Problem Ubuntu Hardy 8.04 EZ Template in Virtuozzo
SSL Zertifikat in Virtuozzo austauschen