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
Next revision Both sides next revision
настройка_сети_в_linux [2022/02/01 09:19]
val [Файлы конфигурации Ubuntu >= 18]
настройка_сети_в_linux [2023/06/14 10:34]
val [Файлы конфигурации Ubuntu >= 18]
Line 85: Line 85:
  
   * [[Использование загрузчика GRUB#​Переименование интерфейсов]]   * [[Использование загрузчика GRUB#​Переименование интерфейсов]]
- 
  
  
Line 91: Line 90:
  
 <​code>​ <​code>​
 +# hostnamectl set-hostname server.corpX.un
 +
 +# cat /​etc/​hostname
 +</​code><​code>​
 +server.corpX.un
 +</​code>​
 +
 # cat /etc/hosts # cat /etc/hosts
 </​code><​code>​ </​code><​code>​
Line 105: Line 111:
 </​code>​ </​code>​
  
-==== Файлы конфигурации Debian/Ubuntu16 ​====+==== Файлы конфигурации ​ifupdown (Debian/Ubuntu<​18) ​====
  
   * [[http://​help.ubuntu.ru/​manual/​подключение_к_интернету|Руководство по Ubuntu. Настройка подключения к интернету]]   * [[http://​help.ubuntu.ru/​manual/​подключение_к_интернету|Руководство по Ubuntu. Настройка подключения к интернету]]
Line 112: Line 118:
 === Статическая настройка параметров === === Статическая настройка параметров ===
 <​code>​ <​code>​
-# cat /​etc/​hostname 
-</​code><​code>​ 
-server.corpX.un 
-</​code><​code>​ 
 # cat /​etc/​network/​interfaces # cat /​etc/​network/​interfaces
 </​code><​code>​ </​code><​code>​
Line 179: Line 181:
  
 <​code>​ <​code>​
 +client1# dhclient eth0
 +
 client1# cat /​etc/​hostname client1# cat /​etc/​hostname
 </​code><​code>​ </​code><​code>​
Line 184: Line 188:
 </​code><​code>​ </​code><​code>​
 client1# :> /​etc/​resolv.conf client1# :> /​etc/​resolv.conf
-</​code><​code>​+</​code>​ 
 + 
 +или [[Система безопасности UNIX#​Команда chattr]] 
 + 
 +<​code>​
 client1# cat /etc/hosts client1# cat /etc/hosts
 </​code><​code>​ </​code><​code>​
Line 216: Line 224:
   * [[https://​linuxconfig.org/​how-to-change-hostname-on-ubuntu-18-04-bionic-beaver-linux|How to change hostname on Ubuntu 18.04 Bionic Beaver Linux]]   * [[https://​linuxconfig.org/​how-to-change-hostname-on-ubuntu-18-04-bionic-beaver-linux|How to change hostname on Ubuntu 18.04 Bionic Beaver Linux]]
   * [[https://​www.linuxtechi.com/​assign-static-ip-address-ubuntu-20-04-lts/​|How to Assign Static IP Address on Ubuntu 20.04 LTS]]   * [[https://​www.linuxtechi.com/​assign-static-ip-address-ubuntu-20-04-lts/​|How to Assign Static IP Address on Ubuntu 20.04 LTS]]
 +  * [[https://​unix.stackexchange.com/​questions/​588658/​override-ubuntu-20-04-dns-using-systemd-resolved|Override Ubuntu 20.04 DNS using systemd-resolved]]
  
-=== Без cloud-init ===+=== Отключение cloud-init ===
 <​code>​ <​code>​
-cat /etc/cloud/​cloud.cfg +# apt purge cloud-init 
-</​code><​code>​ +</​code>​
-... +
-preserve_hostname:​ true +
-... +
-</​code><​code>​ +
-# hostnamectl set-hostname ubuntu.corpX.un +
-</​code>​<​code>​ +
-# echo '​network:​ {config: disabled}'​ > /​etc/​cloud/​cloud.cfg.d/​99-disable-network-config.cfg+
  
-ubuntu18# rm /​etc/​netplan/​50-cloud-init.yaml+=== Настройка Netplan ===
  
-ubuntu20# rm /etc/netplan/00-installer-config.yaml+  * [[Формат YAML]] 
 +  * [[https://netplan.io/faq/​|Netplan FAQ]] 
 +  * [[https://​netplan.io/​examples/​|Netplan configuration examples]] !!! Все варианты !!!
  
 +<​code>​
 # cat /​etc/​netplan/​01-netcfg.yaml # cat /​etc/​netplan/​01-netcfg.yaml
 </​code><​code>​ </​code><​code>​
 network: network:
-    ​version: 2 +  ​version: 2 
-    ethernets:​ +  ethernets:​ 
-        enp0s3: +    enp0s3: 
-            addresses: [172.16.1.200+X/​24] +      addresses: [172.16.1.200+X/​24] 
-            gateway4: 172.16.1.254 +      gateway4: 172.16.1.254 
-            nameservers:​ + 
-                addresses: [172.16.1.254]+#      routes: 
 +#        - to: default 
 +#          via: 172.16.1.254 
 + 
 +#      ​nameservers:​ 
 +#        ​addresses: [172.16.1.254] 
 +</​code><​code>​ 
 +# netplan try 
 + 
 +# netplan apply
 </​code>​ </​code>​
  
-=== Без Netpaln ===+=== Отключение Netpaln ===
  
   * [[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]]   * [[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
 +</​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 (Русский)]]
 +
 +<​code>​
 +# cat /​etc/​resolv.conf
 +</​code><​code>​
 +search corpX.un
 +nameserver 127.0.0.53
 +</​code><​code>​
 +# resolvectl status
 +  или
 +# systemd-resolve --status
 +
 +# cat /​etc/​systemd/​resolved.conf
 +</​code><​code>​
 +[Resolve]
 +DNS=172.16.1.254
 +</​code><​code>​
 +# systemctl restart systemd-resolved
 +</​code>​
 +
 +=== Отключение systemd-resolved ===
 +
   * [[https://​gist.github.com/​zoilomora/​f7d264cefbb589f3f1b1fc2cea2c844c|How to disable systemd-resolved in Ubuntu]]   * [[https://​gist.github.com/​zoilomora/​f7d264cefbb589f3f1b1fc2cea2c844c|How to disable systemd-resolved in Ubuntu]]
 +
 +<​code>​
 +# systemctl disable systemd-resolved
 +
 +# systemctl stop systemd-resolved
 +
 +# rm /​etc/​resolv.conf ​   # this is link
 +</​code>​
 +
 ==== Файлы конфигурации CentOS/​SL/​RHEL ==== ==== Файлы конфигурации CentOS/​SL/​RHEL ====
  
Line 293: Line 347:
 # GATEWAY=172.16.1.254 # GATEWAY=172.16.1.254
 </​code>​ </​code>​
-==== Применение файлов настроек ​====+=== Применение файлов настроек ===
 <​code>​ <​code>​
 # hostname centos.corpX.un # hostname centos.corpX.un
Line 320: Line 374:
 </​code>​ </​code>​
  
-====== Управление разрешением имен (getaddrinfo) ​======+===== Управление разрешением имен (getaddrinfo) =====
 <​code>​ <​code>​
 root@nessus.isp.un:​~#​ host ru.archive.ubuntu.com root@nessus.isp.un:​~#​ host ru.archive.ubuntu.com
Line 333: Line 387:
 precedence 2a02:​6b8::/​32 ​  0 precedence 2a02:​6b8::/​32 ​  0
 ... ...
 +</​code>​
 +
 +===== Настройка bonding =====
 +
 +  * [[https://​www.andreyus.com/​otkazoustoychivost-dostupa-k-seti-v-linux/​|Отказоустойчивость доступа к сети в Linux]]
 +  * [[https://​netberg.ru/​supports/​article/​ethernet-bonding/​|Ethernet bonding — это объединение двух или более физических сетевых интерфейсов в один виртуальный для обеспечения отказоустойчивости и повышения пропускной способности]]
 +
 +
 +==== bond ifupdown ====
 +<​code>​
 +# apt install ifenslave
 +
 +# cat /​etc/​network/​interfaces
 +</​code><​code>​
 +...
 +iface eth0 inet manual
 +
 +iface eth1 inet manual
 +
 +auto bond0
 +iface bond0 inet static
 +        address 192.168.X.10
 +        netmask 255.255.255.0
 +        gateway 192.168.X.1
 +        slaves eth0 eth1
 +        bond-mode active-backup
 +        bond-miimon 100
 +        bond-primary eth0
 +
 +</​code>​
 +
 +==== bond netplan ====
 +<​code>​
 +# cat /​etc/​netplan/​01-netcfg.yaml
 +</​code><​code>​
 +network:
 +  version: 2
 +  bonds:
 +    bond0:
 +      addresses: [192.168.X.10/​24]
 +      gateway4: 192.168.X.1
 +      interfaces: [eth0, eth1]
 +      parameters:
 +        mode: active-backup
 +        mii-monitor-interval:​ 100
 +        primary: eth0
 +  ethernets:
 +    eth0: {}
 +    eth1: {}
 +</​code>​
 +
 +==== Отладка ====
 +<​code>​
 +# cat /​proc/​net/​bonding/​bond0
 </​code>​ </​code>​
настройка_сети_в_linux.txt · Last modified: 2024/05/04 16:16 by val