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 [2022/03/09 10:09]
val [Файлы конфигурации Ubuntu >= 18]
настройка_сети_в_linux [2024/03/16 05:13] (current)
val [Команды для диагностики]
Line 78: Line 78:
  
 # ss -anptu # ss -anptu
 +# ss -lnp | grep ':​80'​
 </​code>​ </​code>​
  
Line 90: Line 91:
  
 <​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 119:
 === Статическая настройка параметров === === Статическая настройка параметров ===
 <​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 182:
  
 <​code>​ <​code>​
 +client1# dhclient eth0
 +
 client1# cat /​etc/​hostname client1# cat /​etc/​hostname
 </​code><​code>​ </​code><​code>​
Line 183: Line 189:
 </​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 219: Line 229:
 === Отключение cloud-init === === Отключение cloud-init ===
 <​code>​ <​code>​
-cat /​etc/​cloud/​cloud.cfg +apt purge cloud-init
-</​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 +
- +
-ubuntu20# rm /​etc/​netplan/​00-installer-config.yaml+
 </​code>​ </​code>​
  
-=== netplan ​===+=== Настройка Netplan ​===
  
   * [[Формат YAML]]   * [[Формат YAML]]
Line 249: Line 247:
       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]
Line 255: Line 258:
  
 # netplan apply # netplan apply
 +</​code>​
  
 +=== Отключение 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]]
 +
 +<​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 # cat /​etc/​resolv.conf
 </​code><​code>​ </​code><​code>​
Line 261: Line 280:
 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>​ </​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]]+  * [[https://gist.github.com/zoilomora/​f7d264cefbb589f3f1b1fc2cea2c844c|How to disable systemd-resolved in Ubuntu]]
  
 <​code>​ <​code>​
-apt install ifupdown net-tools +systemctl disable systemd-resolved
-</​code>​+
  
-=== Без ​systemd-resolved ​=== +# systemctl stop systemd-resolved
-  * [[https://​gist.github.com/​zoilomora/​f7d264cefbb589f3f1b1fc2cea2c844c|How to disable systemd-resolved in Ubuntu]]+
  
-<​code>​ +rm /etc/resolv.conf    ​this is link
-systemctl disable systemd-resolved.service +
-systemctl stop systemd-resolved+
 </​code>​ </​code>​
 +
 ==== Файлы конфигурации CentOS/​SL/​RHEL ==== ==== Файлы конфигурации CentOS/​SL/​RHEL ====
  
Line 374: Line 396:
  
  
-==== ifupdown ====+==== bond ifupdown ====
 <​code>​ <​code>​
 +# apt install ifenslave
 +
 # cat /​etc/​network/​interfaces # cat /​etc/​network/​interfaces
 </​code><​code>​ </​code><​code>​
Line 395: Line 419:
 </​code>​ </​code>​
  
-==== netplan ====+==== bond netplan ====
 <​code>​ <​code>​
 # cat /​etc/​netplan/​01-netcfg.yaml # cat /​etc/​netplan/​01-netcfg.yaml
настройка_сети_в_linux.1646809791.txt.gz · Last modified: 2022/03/09 10:09 by val