User Tools

Site Tools


настройка_сети_в_linux

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
настройка_сети_в_linux [2026/03/30 09:56]
val
настройка_сети_в_linux [2026/05/16 16:48] (current)
val [Использование NetworkManager]
Line 52: Line 52:
  
 # dhcpcd -k enp0s3 # dhcpcd -k enp0s3
 +
 +# pkill -KILL dhcpcd
 </​code>​ </​code>​
  
Line 101: Line 103:
  
 # ss -anptu # ss -anptu
-# ss -lnp | grep ':​80'​+# ss -lnp | grep sshd
  
 # количество подключений с каждого адреса (https://​serverfault.com/​questions/​421310/​check-the-number-of-active-connections-on-port-80) # количество подключений с каждого адреса (https://​serverfault.com/​questions/​421310/​check-the-number-of-active-connections-on-port-80)
Line 120: Line 122:
 </​code><​code>​ </​code><​code>​
 server.corpX.un server.corpX.un
-</​code>​ +</​code>​<​code>​
 # cat /etc/hosts # cat /etc/hosts
 </​code><​code>​ </​code><​code>​
Line 128: Line 129:
 172.16.1.X ​     server.corpX.un server 172.16.1.X ​     server.corpX.un server
 </​code><​code>​ </​code><​code>​
-# apt remove resolvconf+# ###apt remove resolvconf
  
 # cat /​etc/​resolv.conf # cat /​etc/​resolv.conf
Line 145: Line 146:
 === Статическая настройка параметров === === Статическая настройка параметров ===
 <​code>​ <​code>​
 +# ###apt install ifupdown
 +
 # cat /​etc/​network/​interfaces # cat /​etc/​network/​interfaces
 </​code><​code>​ </​code><​code>​
Line 213: Line 216:
  
 client1# :> /​etc/​resolv.conf client1# :> /​etc/​resolv.conf
-</​code>​ 
- 
-или [[Система безопасности UNIX#​Команда chattr]] 
  
-<​code>​ 
 client1# cat /etc/hosts client1# cat /etc/hosts
 </​code><​code>​ </​code><​code>​
Line 233: Line 232:
 auto eth0 auto eth0
 iface eth0 inet dhcp iface eth0 inet dhcp
 +</​code>​
 +
 +=== Отключение ifupdown ===
 +<​code>​
 +# apt purge ifupdown
 +
 +# rm /​etc/​network/​interfaces
 </​code>​ </​code>​
  
 ==== Использование NetworkManager ==== ==== Использование NetworkManager ====
  
-  * Alma Linux и аналоги+  * (Alma Linux аналоги ​и desktop linux)
  
   * [[https://​habr.com/​ru/​companies/​vdsina/​articles/​512282/​|Управляем сетевыми подключениями в Linux с помощью консольной утилиты nmcli]]   * [[https://​habr.com/​ru/​companies/​vdsina/​articles/​512282/​|Управляем сетевыми подключениями в Linux с помощью консольной утилиты nmcli]]
   * [[https://​linuxconfig.org/​rhel-8-configure-static-ip-address|How to configure a static IP address on RHEL 8 / CentOS 8 Linux]]   * [[https://​linuxconfig.org/​rhel-8-configure-static-ip-address|How to configure a static IP address on RHEL 8 / CentOS 8 Linux]]
  
-  * Не работает с net.ifnames=0+  * ??? Не работает с net.ifnames=0 
 +  * [[#​Отключение ifupdown]]
  
 <​code>​ <​code>​
-# apt purge ifupdown 
- 
 # apt install network-manager # apt install network-manager
  
Line 257: Line 262:
 # apt install network-manager-gnome # apt install network-manager-gnome
 </​code>​ </​code>​
-==== Файлы конфигурации ​Ubuntu >18 ====+==== Файлы конфигурации ​Netplan и cloud-init ​==== 
 + 
 +  * (Ubuntu>=18)
  
   * [[https://​cloud.croc.ru/​blog/​byt-v-teme/​cloud-init/​|Cloud-init:​ автоматическая установка hostname для виртуальной машины]]   * [[https://​cloud.croc.ru/​blog/​byt-v-teme/​cloud-init/​|Cloud-init:​ автоматическая установка hostname для виртуальной машины]]
Line 268: Line 275:
  
   * [[https://​cloudinit.readthedocs.io/​en/​latest/​tutorial/​qemu.html|Core tutorial with QEMU]]   * [[https://​cloudinit.readthedocs.io/​en/​latest/​tutorial/​qemu.html|Core tutorial with QEMU]]
 +
 +<​code>​
 +# cat /​etc/​netplan/​50-cloud-init.yaml
 +</​code>​
  
 === Отключение cloud-init === === Отключение cloud-init ===
 <​code>​ <​code>​
 # apt purge cloud-init # apt purge cloud-init
-</​code>​ 
  
-=== Отключение ifupdown === +# rm /​etc/​netplan/​50-cloud-init.yaml
-<​code>​ +
-apt purge ifupdown+
 </​code>​ </​code>​
  
Line 294: Line 302:
   ethernets:   ethernets:
     enp0s3:     enp0s3:
-      addresses: [172.16.1.200+X/24] +      addresses: [172.16.1.100+X/24]
-      gateway4: 172.16.1.254+
  
-#      ​routes: +      ​routes: 
-       - to: default +        - to: default 
-         via: 172.16.1.254+          via: 172.16.1.254
  
-#      ​nameservers:​ +      ​nameservers:​ 
-       ​addresses:​ [172.16.1.254]+        ​search:​ [isp.un] 
 +        ​addresses:​ [172.16.1.254]
 </​code><​code>​ </​code><​code>​
-# netplan try+# netplan get      # lint and print config from files 
 + 
 +# netplan try #--timeout 120
  
 # netplan apply # netplan apply
 </​code>​ </​code>​
  
-=== Отключение Netpaln === +==== Настройка systemd-resolved ​====
- +
-  * [[https://​linuxconfig.org/​how-to-switch-back-networking-to-etc-network-interfaces-on-ubuntu-20-04-focal-fossa-linux|How to switch back networking to /​etc/​network/​interfaces on Ubuntu 20.04 Focal Fossa Linux]] +
- +
-<​code>​ +
-# apt install ifupdown net-tools +
- +
-ubuntu20/​22#​ rm /​etc/​netplan/​00-installer-config.yaml +
- +
-ubuntu24# rm /​etc/​netplan/​50-cloud-init.yaml +
-</​code>​ +
- +
-=== Настройка systemd-resolved ===+
  
   * [[https://​wiki.archlinux.org/​title/​Systemd-resolved_(%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9)|archlinux systemd-resolved (Русский)]]   * [[https://​wiki.archlinux.org/​title/​Systemd-resolved_(%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9)|archlinux systemd-resolved (Русский)]]
Line 357: Line 355:
 ==== Файлы конфигурации initscripts ==== ==== Файлы конфигурации initscripts ====
  
-  * CentOS/​SL/​RHEL 6,7 до NetworkManager ​+  * CentOS/​SL/​RHEL 6,7,8 до NetworkManager ​
  
   * [[http://​serveradmin.ru/​nastroyka-seti-v-centos/#​_hostname_CentOS_7|Сетевые настройки в CentOS 7]]   * [[http://​serveradmin.ru/​nastroyka-seti-v-centos/#​_hostname_CentOS_7|Сетевые настройки в CentOS 7]]
настройка_сети_в_linux.1774853794.txt.gz · Last modified: 2026/03/30 09:56 by val