Este conteúdo foi traduzido por máquina para sua conveniência e a Huawei Cloud não pode garantir que o conteúdo foi traduzido com precisão. Para exibir o conteúdo original, use o link no canto superior direito para mudar para a página em inglês.
Central de ajuda> Bare Metal Server> Guia de usuário> Rede> VLAN definida pelo usuário> Configuração de uma VLAN definida pelo usuário (SUSE Linux Enterprise Server 12)
Atualizado em 2023-05-09 GMT+08:00

Configuração de uma VLAN definida pelo usuário (SUSE Linux Enterprise Server 12)

O segmento de rede da VLAN definida pelo usuário não pode sobrepor as informações de rede configuradas no BMS.

Esta seção usa o SUSE Linux Enterprise Server 12 SP1 (x86_64) como um exemplo para descrever como configurar uma VLAN definida pelo usuário para BMSs.

  1. Use uma chave ou senha para fazer logon no BMS como usuário root.
  2. Na CLI do BMS, execute o seguinte comando para verificar as informações da NIC:

    ip link

    Informação semelhante à seguinte é exibida.

    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default 
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    2: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 8888 qdisc mq master bond0 state UP mode DEFAULT group default qlen 1000
        link/ether fa:16:3e:3d:1c:e0 brd ff:ff:ff:ff:ff:ff
    3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 8888 qdisc mq master bond0 state UP mode DEFAULT group default qlen 1000
        link/ether fa:16:3e:3d:1c:e0 brd ff:ff:ff:ff:ff:ff
    4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
        link/ether 38:4c:4f:89:55:8d brd ff:ff:ff:ff:ff:ff
    5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
        link/ether 38:4c:4f:89:55:8e brd ff:ff:ff:ff:ff:ff
    6: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 8888 qdisc noqueue state UP mode DEFAULT group default 
        link/ether fa:16:3e:3d:1c:e0 brd ff:ff:ff:ff:ff:ff
    7: bond0.3133@bond0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 8888 qdisc noqueue state UP mode DEFAULT group default 
        link/ether fa:16:3e:57:87:6e brd ff:ff:ff:ff:ff:ff

    Entre os dispositivos, eth0 e eth1 possuem a VPC, e eth2 e eth3 possuem a VLAN definida pelo usuário.

  3. Configure as regras do udev:

    Execute o seguinte comando para criar o arquivo 80-persistent-net.rules:

    cp /etc/udev/rules.d/70-persistent-net.rules /etc/udev/rules.d/80-persistent-net.rules

    Escreva o endereço MAC de NIC e o nome que são consultados dentro 2 e que não são indicados em 80-persistent-net.rules ao arquivo. Dessa forma, depois que o BMS for reiniciado, o nome e a sequência da NIC não serão alterados.

    Certifique-se de que o endereço MAC da NIC e o nome sejam letras minúsculas.

    vim /etc/udev/rules.d/80-persistent-net.rules

    O resultado da modificação é o seguinte:

    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="38:4c:4f:29:0b:e0", NAME="eth0"
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="38:4c:4f:29:0b:e1", NAME="eth1"
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="38:4c:4f:89:55:8d", NAME="eth2"
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="38:4c:4f:89:55:8e", NAME="eth3"

    Após a modificação, salve a alteração e saia.

  4. Execute o seguinte comando para verificar o endereço IP da NIC:

    ifconfig

    Informações semelhantes às seguintes são exibidas, onde bond0 e bond0.313 mostram os endereços IP da NIC alocados automaticamente pelo sistema quando você se inscreve para o BMS:

    bond0     Link encap:Ethernet  HWaddr FA:16:3E:3D:1C:E0  
              inet addr:10.0.1.2  Bcast:10.0.1.255  Mask:255.255.255.0
              inet6 addr: fe80::f816:3eff:fe3d:1ce0/64 Scope:Link
              UP BROADCAST RUNNING MASTER MULTICAST  MTU:8888  Metric:1
              RX packets:852 errors:0 dropped:160 overruns:0 frame:0
              TX packets:1121 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:125429 (122.4 Kb)  TX bytes:107221 (104.7 Kb)
    
    bond0.313 Link encap:Ethernet  HWaddr FA:16:3E:57:87:6E  
              inet addr:10.0.3.2  Bcast:10.0.3.255  Mask:255.255.255.0
              inet6 addr: fe80::f816:3eff:fe57:876e/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:8888  Metric:1
              RX packets:169 errors:0 dropped:0 overruns:0 frame:0
              TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:8684 (8.4 Kb)  TX bytes:1696 (1.6 Kb)
    
    eth0      Link encap:Ethernet  HWaddr FA:16:3E:3D:1C:E0  
              UP BROADCAST RUNNING SLAVE MULTICAST  MTU:8888  Metric:1
              RX packets:428 errors:0 dropped:10 overruns:0 frame:0
              TX packets:547 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:64670 (63.1 Kb)  TX bytes:50132 (48.9 Kb)
    
    eth1      Link encap:Ethernet  HWaddr FA:16:3E:3D:1C:E0  
              UP BROADCAST RUNNING SLAVE MULTICAST  MTU:8888  Metric:1
              RX packets:424 errors:0 dropped:7 overruns:0 frame:0
              TX packets:574 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:60759 (59.3 Kb)  TX bytes:57089 (55.7 Kb)
    
    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:65536  Metric:1
              RX packets:8 errors:0 dropped:0 overruns:0 frame:0
              TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:520 (520.0 b)  TX bytes:520 (520.0 b)

  5. Execute os seguintes comandos para verificar os nomes das NICs vinculadas:

    As NICs vinculadas em serviço não podem ser usadas no plano de comunicação interna. Portanto, você deve obtê-las pelo nome.

    cd /etc/sysconfig/network

    vi ifcfg-bond0

    Informações semelhantes às seguintes são exibidas, onde bond0 é composto de NICs eth0 e eth1:

    BONDING_MASTER=yes
    TYPE=Bond
    STARTMODE=auto
    BONDING_MODULE_OPTS="mode=4 xmit_hash_policy=layer3+4 miimon=100"
    NM_CONTROLLED=no
    BOOTPROTO=dhcp
    DEVICE=bond0
    USERCONTRL=no
    LLADDR=fa:16:3e:3d:1c:e0
    BONDING_SLAVE1=eth1
    BONDING_SLAVE0=eth0

    Após a consulta, saia.

  6. Execute os seguintes comandos para verificar os status de todas as NICs:

    ip link

    Informação semelhante à seguinte é exibida.

    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default 
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    2: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 8888 qdisc mq master bond0 state UP mode DEFAULT group default qlen 1000
        link/ether fa:16:3e:3d:1c:e0 brd ff:ff:ff:ff:ff:ff
    3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 8888 qdisc mq master bond0 state UP mode DEFAULT group default qlen 1000
        link/ether fa:16:3e:3d:1c:e0 brd ff:ff:ff:ff:ff:ff
    4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
        link/ether 38:4c:4f:89:55:8d brd ff:ff:ff:ff:ff:ff
    5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
        link/ether 38:4c:4f:89:55:8e brd ff:ff:ff:ff:ff:ff
    6: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 8888 qdisc noqueue state UP mode DEFAULT group default 
        link/ether fa:16:3e:3d:1c:e0 brd ff:ff:ff:ff:ff:ff
    7: bond0.3133@bond0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 8888 qdisc noqueue state UP mode DEFAULT group default 
        link/ether fa:16:3e:57:87:6e brd ff:ff:ff:ff:ff:ff

  7. Execute os seguintes comandos para alterar o status da NIC qdisc mq state DOWN para qdisc mq state UP. Os comandos a seguir usam NICs eth2 e eth3 como exemplos.

    ip link set eth2 up

    ip link set eth3 up

  8. Execute os seguintes comandos para verificar os status de todas as NICs:

    ip link

    Informação semelhante à seguinte é exibida.

    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default 
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    2: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 8888 qdisc mq master bond0 state UP mode DEFAULT group default qlen 1000
        link/ether fa:16:3e:3d:1c:e0 brd ff:ff:ff:ff:ff:ff
    3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 8888 qdisc mq master bond0 state UP mode DEFAULT group default qlen 1000
        link/ether fa:16:3e:3d:1c:e0 brd ff:ff:ff:ff:ff:ff
    4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
        link/ether 38:4c:4f:89:55:8d brd ff:ff:ff:ff:ff:ff
    5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
        link/ether 38:4c:4f:89:55:8e brd ff:ff:ff:ff:ff:ff
    6: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 8888 qdisc noqueue state UP mode DEFAULT group default 
        link/ether fa:16:3e:3d:1c:e0 brd ff:ff:ff:ff:ff:ff
    7: bond0.3133@bond0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 8888 qdisc noqueue state UP mode DEFAULT group default 
        link/ether fa:16:3e:57:87:6e brd ff:ff:ff:ff:ff:ff

  9. Verifique os status das NICs em 8 e obtenha os nomes das NICs em estado qdisc mq state UP .

    Somente as NICs que estão em estado qdisc mq state UP e não foram usadas​podem ser vinculadas. Neste exemplo, tais NICs são eth2 e eth3.

    Os valores LLADR das NICs eth2 e eth3 são 38:4c:4f:89:55:8d e 38:4c:4f:89:55:8erespectivamente.

  10. Execute os seguintes comandos para criar os arquivos de configuração das NICs eth2 e eth3:

    você pode copiar um arquivo de configuração da NIC existente e modificá-lo para melhorar a eficiência da criação.

    cp ifcfg-eth0 ifcfg-eth2

    cp ifcfg-eth1 ifcfg-eth3

  11. Execute os seguintes comandos para modificar os arquivos de configuração das NICs eth2 e eth3:

    vi ifcfg-eth2

    vi ifcfg-eth3

    Arquivo de configuração modificado da NIC eth2 é o seguinte.

    Neste arquivo de configuração, defina MTU para 8888, BOOTPROTO para STATIC, e configure DEVICE e LLADDR conforme necessário.

    STARTMODE=auto
    MTU=8888
    NM_CONTROLLED=no
    BOOTPROTO=STATIC
    DEVICE=eth2
    USERCONTRL=no
    LLADDR=38:4c:4f:89:55:8d
    TYPE=Ethernet

    Arquivo de configuração modificado da NIC eth3 é o seguinte:

    STARTMODE=auto
    MTU=8888
    NM_CONTROLLED=no
    BOOTPROTO=STATIC
    DEVICE=eth3
    USERCONTRL=no
    LLADDR=38:4c:4f:89:55:8e
    TYPE=Ethernet

    Após a modificação, salve a alteração e saia.

  12. Execute o seguinte comando para ligar NICs eth2 e eth3 a uma NIC, por exemplo, bond1:

    execute os comandos a seguir para criar o arquivo ifcfg-bond1 e modificar o arquivo de configuração:

    cp ifcfg-bond0 ifcfg-bond1

    vi ifcfg-bond1

    Arquivo de configuração modificado da NIC bond1 é o seguinte.

    Neste arquivo de configuração, MTU é definido como 8888, BONDING_MODULE_OPTS é definido como mode=1 miimon=100, BOOTPROTO está definido para STATIC. DEVICE, BONDING_SLAVE1, BONDING_SLAVE0, IPADDR, NETMASK e NETWORK são configurados conforme necessário. LLADDR é definido como o valor LLADDR da NIC BONDING_SLAVE1.

    BONDING_MASTER=yes
    TYPE=Bond
    MTU=8888
    STARTMODE=auto
    BONDING_MODULE_OPTS="mode=1 miimon=100"
    NM_CONTROLLED=no
    BOOTPROTO=STATIC
    DEVICE=bond1
    USERCONTRL=no
    LLADDR=38:4c:4f:89:55:8d
    BONDING_SLAVE1=eth2
    BONDING_SLAVE0=eth3
    IPADDR=10.0.2.2
    NETMASK=255.255.255.0
    NETWORK=10.0.2.0

    Após a modificação, salve a alteração e saia.

  13. Faça o arquivo de configuração entrar em vigor.

    1. Execute os seguintes comandos para criar um diretório temporário e copiar o arquivo de configuração de NIC para este diretório:

      mkdir /opt/tmp/

      mkdir /opt/tmp/xml

      cp /etc/sysconfig/network/ifcfg* /opt/tmp/

      cp /etc/sysconfig/network/config /opt/tmp/

      cp /etc/sysconfig/network/dhcp /opt/tmp/

    2. Execute os seguintes comandos para parar as NICs para formar o bond1:

      ip link set eth2 down

      ip link set eth3 down

    3. Execute o seguinte comando para converter o arquivo de configuração de NIC em um arquivo de configuração que possa ser reconhecido pelo sistema operacional:

      /usr/sbin/wicked --log-target=stderr --log-level=debug3 --debug all convert --output /opt/tmp/xml /opt/tmp/

    4. Execute os seguintes comandos para reiniciar as NICs para formar bond1:

      ip link set eth2 up

      /usr/sbin/wicked --log-target=stderr --log-level=debug3 --debug all ifup --ifconfig /opt/tmp/xml/eth2.xml eth2

      ip link set eth3 up

      /usr/sbin/wicked --log-target=stderr --log-level=debug3 --debug all ifup --ifconfig /opt/tmp/xml/eth3.xml eth3

      /usr/sbin/wicked --log-target=stderr --log-level=debug3 --debug all ifup --ifconfig /opt/tmp/xml/bond1.xml bond1

  14. Execute o seguinte comando para consultar endereços IP:

    ip addr show

    Um exemplo é fornecido como a seguir:

    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host 
           valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 8888 qdisc mq master bond0 state UP group default qlen 1000
        link/ether fa:16:3e:3d:1c:e0 brd ff:ff:ff:ff:ff:ff
    3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 8888 qdisc mq master bond0 state UP group default qlen 1000
        link/ether fa:16:3e:3d:1c:e0 brd ff:ff:ff:ff:ff:ff
    4: eth2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 8888 qdisc mq master bond1 state UP group default qlen 1000
        link/ether 38:4c:4f:89:55:8d brd ff:ff:ff:ff:ff:ff
    5: eth3: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 8888 qdisc mq master bond1 state UP group default qlen 1000
        link/ether 38:4c:4f:89:55:8d brd ff:ff:ff:ff:ff:ff
    6: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 8888 qdisc noqueue state UP group default 
        link/ether fa:16:3e:3d:1c:e0 brd ff:ff:ff:ff:ff:ff
        inet 10.0.1.2/24 brd 10.0.1.255 scope global bond0
           valid_lft forever preferred_lft forever
        inet6 fe80::f816:3eff:fe3d:1ce0/64 scope link 
           valid_lft forever preferred_lft forever
    7: bond0.3133@bond0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 8888 qdisc noqueue state UP group default 
        link/ether fa:16:3e:57:87:6e brd ff:ff:ff:ff:ff:ff
        inet 10.0.3.2/24 brd 10.0.2.255 scope global bond0.3133
           valid_lft forever preferred_lft forever
        inet6 fe80::f816:3eff:fe57:876e/64 scope link 
           valid_lft forever preferred_lft forever
    8: bond1: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 8888 qdisc noqueue state UP group default 
        link/ether 38:4c:4f:89:55:8d brd ff:ff:ff:ff:ff:ff
        inet 10.0.2.2/24 brd 10.0.2.255 scope global bond1
           valid_lft forever preferred_lft forever
        inet6 fe80::3a4c:4fff:fe29:b36/64 scope link 
           valid_lft forever preferred_lft forever

  15. Execute os seguintes comandos para excluir o diretório temporário:

    cd /opt

    rm -rf tmp/

  16. Repita as operações anteriores para configurar outros BMSs.