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/23 14:03]
val [Настройка bonding]
настройка_сети_в_linux [2023/06/14 10:19]
val [Файлы конфигурации Ubuntu >= 18]
Line 90: 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 111: 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 178: Line 181:
  
 <​code>​ <​code>​
 +client1# dhclient eth0
 +
 client1# cat /​etc/​hostname client1# cat /​etc/​hostname
 </​code><​code>​ </​code><​code>​
Line 183: 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 217: Line 226:
   * [[https://​unix.stackexchange.com/​questions/​588658/​override-ubuntu-20-04-dns-using-systemd-resolved|Override Ubuntu 20.04 DNS using systemd-resolved]]   * [[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>​
Line 241: Line 246:
       addresses: [172.16.1.200+X/​24]       addresses: [172.16.1.200+X/​24]
       gateway4: 172.16.1.254       gateway4: 172.16.1.254
 +
 +#      routes:
 +#        - to: default
 +#          via: 172.16.1.254
 +
 #      nameservers:​ #      nameservers:​
 #        addresses: [172.16.1.254] #        addresses: [172.16.1.254]
 </​code><​code>​ </​code><​code>​
 +# netplan try
 +
 # netplan apply # netplan apply
 +</​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 # cat /​etc/​resolv.conf
 </​code><​code>​ </​code><​code>​
Line 251: Line 268:
 nameserver 127.0.0.53 nameserver 127.0.0.53
 </​code><​code>​ </​code><​code>​
 +# resolvectl status
 +  или
 +# systemd-resolve --status
 +
 # cat /​etc/​systemd/​resolved.conf # cat /​etc/​systemd/​resolved.conf
 </​code><​code>​ </​code><​code>​
 [Resolve] [Resolve]
 DNS=172.16.1.254 DNS=172.16.1.254
 +</​code><​code>​
 +# systemctl restart systemd-resolved
 +</​code>​
 +
 +=== Без systemd-resolved ===
 +<​code>​
 +# systemctl disable systemd-resolved
 +
 +# systemctl stop systemd-resolved
 +
 +# rm /​etc/​resolv.conf
 </​code>​ </​code>​
  
Line 263: Line 295:
 <​code>​ <​code>​
 # apt install ifupdown net-tools # apt install ifupdown net-tools
 +
 +# echo '​network:​ {config: disabled}'​ > /​etc/​cloud/​cloud.cfg.d/​99-disable-network-config.cfg
 +
 +ubuntu18# rm /​etc/​netplan/​50-cloud-init.yaml
 +
 +ubuntu20/​22#​ rm /​etc/​netplan/​00-installer-config.yaml
 </​code>​ </​code>​
  
Line 271: Line 309:
 # systemctl disable systemd-resolved.service # systemctl disable systemd-resolved.service
 # systemctl stop systemd-resolved # systemctl stop systemd-resolved
 +
 +# rm /​etc/​resolv.conf ​   # this is link
 </​code>​ </​code>​
 ==== Файлы конфигурации CentOS/​SL/​RHEL ==== ==== Файлы конфигурации CentOS/​SL/​RHEL ====
Line 363: Line 403:
   * [[https://​netberg.ru/​supports/​article/​ethernet-bonding/​|Ethernet bonding — это объединение двух или более физических сетевых интерфейсов в один виртуальный для обеспечения отказоустойчивости и повышения пропускной способности]]   * [[https://​netberg.ru/​supports/​article/​ethernet-bonding/​|Ethernet bonding — это объединение двух или более физических сетевых интерфейсов в один виртуальный для обеспечения отказоустойчивости и повышения пропускной способности]]
  
 +
 +==== bond ifupdown ====
 <​code>​ <​code>​
-cat /​proc/​net/​bonding/​bond0 +apt install ifenslave 
-</​code>​ +
-==== ifupdown ==== +
-<​code>​+
 # cat /​etc/​network/​interfaces # cat /​etc/​network/​interfaces
 </​code><​code>​ </​code><​code>​
Line 383: Line 423:
         bond-mode active-backup         bond-mode active-backup
         bond-miimon 100         bond-miimon 100
-        bond-primary eth0 eth1+        bond-primary eth0
  
 </​code>​ </​code>​
  
-==== netplan ====+==== bond netplan ====
 <​code>​ <​code>​
 # cat /​etc/​netplan/​01-netcfg.yaml # cat /​etc/​netplan/​01-netcfg.yaml
Line 401: Line 441:
         mode: active-backup         mode: active-backup
         mii-monitor-interval:​ 100         mii-monitor-interval:​ 100
 +        primary: eth0
   ethernets:   ethernets:
     eth0: {}     eth0: {}
     eth1: {}     eth1: {}
 +</​code>​
 +
 +==== Отладка ====
 +<​code>​
 +# cat /​proc/​net/​bonding/​bond0
 </​code>​ </​code>​
настройка_сети_в_linux.txt · Last modified: 2024/05/04 16:16 by val