Cómo agregar varias tarjetas de red a una máquina virtual Linux

Cómo agregar varias tarjetas de red a una máquina virtual Linux

Agregar una tarjeta de red en una máquina virtual VMWare requiere dos pasos: (1) agregar un adaptador de red; (2) modificar el archivo de configuración de la tarjeta de red.

1. Agregue un adaptador de red (tarjeta de red)

1. Haga clic en [Máquina virtual] ===> [Configuración] en la máquina virtual VMWare, seleccione [Adaptador de red] en la ventana emergente, haga clic en el botón [Agregar] y seleccione [Red] en la ventana [Asistente para agregar hardware]. adaptador】. Como se muestra abajo:

Inserte la descripción de la imagen aquí

2. Haga clic en el botón [Siguiente] y seleccione el modo de conexión de red requerido según sus necesidades en la ventana emergente. Luego reinicie el sistema.

Inserte la descripción de la imagen aquí

Dos, modifique el archivo de configuración de la tarjeta de red

Después de agregar la tarjeta de red, usando ipconfig no se puede ver la información de la nueva tarjeta de red.

[root@oracle network-scripts]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:B3:93:61  
          inet addr:192.168.1.202  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:feb3:9361/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:578 errors:0 dropped:0 overruns:0 frame:0
          TX packets:202 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:49773 (48.6 KiB)  TX bytes:24682 (24.1 KiB)

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: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)

1. Utilice el archivo de configuración de la tarjeta de red ifcfg-eth0 para generar el archivo de configuración de la tarjeta de red recién agregada.

[root@oracle network-scripts]# cd /etc/sysconfig/network-scripts

[root@oracle network-scripts]# cp /etc/sysconfig/network-scripts/ifcfg-eth0 ifcfg-eth1

[root@oracle network-scripts]# ls ifcfg*
ifcfg-eth0  ifcfg-eth1  ifcfg-lo

2. Edite el archivo de configuración ifcfg-eth1

[root@oracle network-scripts]# vim ifcfg-eth1

DEVICE=eth0
HWADDR=00:0C:29:B3:93:61
TYPE=Ethernet
UUID=cd246f31-87fd-4a26-a070-ccc6f8ed1c7a
ONBOOT=yes
BOOTPROTO=static
NM_CONTROLLED=yes

IPADDR=192.168.220.202
PREFIX=24
# GATEWAY=192.168.80.2
DNS1=192.168.80.2
DNS2=8.8.8.8

3. Reinicie y verifique la información de la red

[root@oracle network-scripts]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:B3:93:61  
          inet addr:192.168.1.202  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:feb3:9361/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2736 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2004 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:214479 (209.4 KiB)  TX bytes:232186 (226.7 KiB)

eth1      Link encap:Ethernet  HWaddr 00:0C:29:B3:93:6B  
          inet addr:192.168.80.202  Bcast:192.168.80.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:feb3:936b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:96 errors:0 dropped:0 overruns:0 frame:0
          TX packets:72 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:8370 (8.1 KiB)  TX bytes:4992 (4.8 KiB)

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:18 errors:0 dropped:0 overruns:0 frame:0
          TX packets:18 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1604 (1.5 KiB)  TX bytes:1604 (1.5 KiB)

En tercer lugar, configure la tarjeta de red: use una tarjeta de red para acceder a la red externa y otra tarjeta de red para acceder a la LAN

1. Configure la puerta de enlace de la tarjeta de red externa

[root@oracle network-scripts]# vim /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=oracle.example.com
GATEWAY=192.168.1.1   ##配置为外网网卡的网关

2. Configurar DNS

Se pueden configurar varios DNS, los resultados son los siguientes:

[root@oracle network-scripts]# vim /etc/resolv.conf

; generated by /sbin/dhclient-script
search localdomain oracle
nameserver 192.168.1.1
nameserver 192.168.80.2
nameserver 8.8.8.8

3. Configure la dirección IP de la tarjeta de red externa.

La tarjeta de red externa debe configurarse con una puerta de enlace, y los resultados son los siguientes:

[root@oracle network-scripts]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
HWADDR=00:0C:29:B3:93:61
TYPE=Ethernet
UUID=cd246f31-87fd-4a26-a070-ccc6f8ed1c7a
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static

IPADDR=192.168.1.202
PREFIX=24
GATEWAY=192.168.1.1   #网关
DNS1=192.168.1.1
DNS2=8.8.8.8

4. Configure la dirección IP de la tarjeta de red interna.

La tarjeta de red externa no puede configurar la puerta de enlace, el resultado es el siguiente:

[root@oracle network-scripts]# vim /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static

IPADDR=192.168.80.202
PREFIX=24

5. Reinicie el servicio de red.

Reinicie el servicio de red y pruebe la red:

[root@wgx network-scripts]# service network restart
正在关闭接口 eth0:                                        [确定]
正在关闭接口 eth1:                                        [确定]
关闭环回接口:                                             [确定]
弹出环回接口:                                             [确定]
弹出界面 eth0: Determining if ip address 192.168.1.201 is already in use for device eth0...
                                                           [确定]
弹出界面 eth1: Determining if ip address 192.168.80.201 is already in use for device eth1...
                                                           [确定]
[root@wgx network-scripts]# ping www.baidu.com
PING www.a.shifen.com (61.135.169.121) 56(84) bytes of data.
64 bytes from 61.135.169.121: icmp_seq=1 ttl=44 time=75.6 ms
64 bytes from 61.135.169.121: icmp_seq=2 ttl=44 time=409 ms
64 bytes from 61.135.169.121: icmp_seq=3 ttl=44 time=76.3 ms
64 bytes from 61.135.169.121: icmp_seq=4 ttl=44 time=97.1 ms
64 bytes from 61.135.169.121: icmp_seq=5 ttl=44 time=83.4 ms
64 bytes from 61.135.169.121: icmp_seq=6 ttl=44 time=77.9 ms
^C
--- www.a.shifen.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5378ms
rtt min/avg/max/mdev = 75.612/136.690/409.576/122.258 ms

Supongo que te gusta

Origin blog.csdn.net/weixin_44377973/article/details/105565047
Recomendado
Clasificación