Ubuntu (2) [Administración de red-IP estática]

1.Ubuntu14.04LTS

1. Información de la versión

cat /proc/version
Linux version 4.4.0-148-generic (buildd@lgw01-amd64-014) (gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.4) ) #174~14.04.1-Ubuntu SMP Thu May 9 08:17:37 UTC 2019

Inserte la descripción de la imagen aquí

2. Configuración de IP estática

1. Obtenga información actual de la red

1. Obtener información de la puerta de enlace

route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.234.2   0.0.0.0         UG    0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.234.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0

Inserte la descripción de la imagen aquí

2. Obtenga información de IP

ifconfig
docker0   Link encap:Ethernet  HWaddr 02:42:91:d4:70:77
          inet addr:172.17.0.1  Bcast:172.17.255.255  Mask:255.255.0.0
          UP BROADCAST 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)

eth0      Link encap:Ethernet  HWaddr 00:0c:29:58:0d:f8
          inet addr:192.168.234.100  Bcast:192.168.234.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe58:df8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:803 errors:0 dropped:0 overruns:0 frame:0
          TX packets:814 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:250601 (250.6 KB)  TX bytes:103036 (103.0 KB)
          Interrupt:19 Base address:0x2000

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:123 errors:0 dropped:0 overruns:0 frame:0
          TX packets:123 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:8881 (8.8 KB)  TX bytes:8881 (8.8 KB)

Inserte la descripción de la imagen aquí
Si no puede ejecutar el comando ifconfig, debe instalar la herramienta net-tools

sudo apt install -y net-tools
Tarjeta de red IP (inet addr) Dirección de transmisión (Bcast) Mascara
eth0 192.168.234.100 192.168.234.255 255.255.255.0

Necesita ser modificado para:

Tarjeta de red IP (inet addr) Dirección de transmisión (Bcast) Mascara
eth0 192.168.234.60 192.168.234.255 255.255.255.0

2. Modificar / etc / network / interfaces

sudo vim /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

Inserte la descripción de la imagen aquí
Modifíquese como sigue:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.234.60
netmask 255.255.255.0
gateway 192.168.234.2
dns-nameservers 114.114.114.114

Inserte la descripción de la imagen aquí

dns-nameservers tampoco puede completar aquí, debe agregar un servidor de nombres 114.114.114.114 en: sudo vim /etc/resolv.conf, es más problemático, por lo que es más conveniente agregar dns-nameservers 114.114.114.114 directamente aquí

3. Modifique /etc/NetworkManager/NetworkManager.conf

sudo vim /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq

[ifupdown]
managed=false

Inserte la descripción de la imagen aquí
Modificar [gestionado = verdadero]:

[main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq

[ifupdown]
managed=true

Inserte la descripción de la imagen aquí

4. Reiniciar

¿Por qué no reiniciar la red, sino reiniciar la máquina?
Porque la ejecución: sudo /etc/init.d/networking restart a menudo no funciona

sudo reboot

3. Prueba

1. Prueba de información de red

ifconfig

Inserte la descripción de la imagen aquí

2. Prueba de red

curl -X GET "http://www.baidu.com"

Inserte la descripción de la imagen aquí

2.Ubuntu16.04LTS

1. Información de la versión

cat /proc/version
Linux version 4.15.0-96-generic (buildd@lgw01-amd64-007) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12)) #97~16.04.1-Ubuntu SMP Wed Apr 1 03:03:31 UTC 2020

Inserte la descripción de la imagen aquí

2. Configuración de IP estática

1. Obtenga información actual de la red

1. Obtener información de la puerta de enlace

route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.234.2   0.0.0.0         UG    100    0        0 ens33
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 ens33
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.234.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33

Inserte la descripción de la imagen aquí

2. Obtenga información de IP

ifconfig
docker0   Link encap:Ethernet  HWaddr 02:42:a8:77:b0:51
          inet addr:172.17.0.1  Bcast:172.17.255.255  Mask:255.255.0.0
          UP BROADCAST 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)

ens33     Link encap:Ethernet  HWaddr 00:0c:29:c5:27:c8
          inet addr:192.168.234.129  Bcast:192.168.234.255  Mask:255.255.255.0
          inet6 addr: fe80::a35e:af29:2935:9820/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2311 errors:0 dropped:0 overruns:0 frame:0
          TX packets:618 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1447686 (1.4 MB)  TX bytes:54078 (54.0 KB)
          Interrupt:19 Base address:0x2000

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:290 errors:0 dropped:0 overruns:0 frame:0
          TX packets:290 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:25128 (25.1 KB)  TX bytes:25128 (25.1 KB)

Inserte la descripción de la imagen aquí
Si no puede ejecutar el comando ifconfig, debe instalar la herramienta net-tools

sudo apt install -y net-tools
Tarjeta de red IP (inet addr) Dirección de transmisión (Bcast) Mascara
ens33 192.168.234.129 192.168.234.255 255.255.255.0

Necesita ser modificado para:

Tarjeta de red IP (inet addr) Dirección de transmisión (Bcast) Mascara
ens33 192.168.234.61 192.168.234.255 255.255.255.0

2. Modificar / etc / network / interfaces

sudo vim /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

Inserte la descripción de la imagen aquí
Modifíquese como sigue:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto ens33
iface ens33 inet static
address 192.168.234.61
netmask 255.255.255.0
gateway 192.168.234.2

Inserte la descripción de la imagen aquí

3. Modifique /etc/NetworkManager/NetworkManager.conf

sudo vim /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq

[ifupdown]
managed=false

Inserte la descripción de la imagen aquí
Modificar [gestionado = verdadero]:

[main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq

[ifupdown]
managed=true

Inserte la descripción de la imagen aquí

4. Modificar /etc/resolvconf/resolv.conf.d/base

sudo vim /etc/resolvconf/resolv.conf.d/base

Añadir:

nameserver 114.114.114.114

Inserte la descripción de la imagen aquí

5. Reiniciar la red

sudo /etc/init.d/networking restart

Inserte la descripción de la imagen aquí
Si la prueba falla, reinicie la computadora directamente

sudo reboot

3. Prueba

1. Prueba de información de red

ifconfig

Inserte la descripción de la imagen aquí

2. Prueba de red

curl -X GET "http://www.baidu.com"

Inserte la descripción de la imagen aquí

3.Ubuntu18.04LTS

1. Información de la versión

cat /proc/version
Linux version 5.3.0-46-generic (buildd@lcy01-amd64-013) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #38~18.04.1-Ubuntu SMP Tue Mar 31 04:17:56 UTC 2020

Inserte la descripción de la imagen aquí

2. Configuración de IP estática

1. Obtenga información actual de la red

1. Obtener información de la puerta de enlace

route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.234.2   0.0.0.0         UG    100    0        0 ens33
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 ens33
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.234.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33

Inserte la descripción de la imagen aquí

2. Obtenga información de IP

ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:a2:55:db:1a  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.234.133  netmask 255.255.255.0  broadcast 192.168.234.255
        inet6 fe80::20c:29ff:fe1e:a361  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:1e:a3:61  txqueuelen 1000  (Ethernet)
        RX packets 2567  bytes 320945 (320.9 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 434  bytes 55474 (55.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 19  base 0x2000

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 261  bytes 22051 (22.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 261  bytes 22051 (22.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Inserte la descripción de la imagen aquí
Si no puede ejecutar el comando ifconfig, debe instalar la herramienta net-tools

sudo apt install -y net-tools
Tarjeta de red IP (inet addr) Dirección de transmisión (Bcast) Mascara
ens33 192.168.234.133 192.168.234.255 255.255.255.0

Necesita ser modificado para:

Tarjeta de red IP (inet addr) Dirección de transmisión (Bcast) Mascara
ens33 192.168.234.62 192.168.234.255 255.255.255.0

2. Modifique /etc/netplan/01-network-manager-all.yaml

sudo vim /etc/netplan/01-network-manager-all.yaml

Modifíquese como sigue:

# Let NetworkManager manage all devices on this system
network:
 version: 2
 renderer: NetworkManager

 ethernets:
  ens33:
   dhcp4: no
   dhcp6: no
   addresses: [192.168.234.62/24]
   gateway4: 192.168.234.2
   nameservers: 
        addresses: [114.114.114.114,8.8.8.8]

Inserte la descripción de la imagen aquí

3. Modificación de la aplicación

sudo netplan apply

Inserte la descripción de la imagen aquí
Si la prueba falla, reinicie la computadora directamente

sudo reboot

3. Prueba

1. Prueba de información de red

ifconfig

Inserte la descripción de la imagen aquí

2. Prueba de red

curl -X GET "http://www.baidu.com"

Inserte la descripción de la imagen aquí

48 artículos originales publicados · Me gustaron 14 · Visitas 4148

Supongo que te gusta

Origin blog.csdn.net/weixin_42366378/article/details/105498199
Recomendado
Clasificación