Home | 簡體中文 | 繁體中文 | 雜文 | 知乎專欄 | Github | OSChina 博客 | 雲社區 | 雲棲社區 | Facebook | Linkedin | 視頻教程 | 打賞(Donations) | About
知乎專欄多維度架構 微信號 netkiller-ebook | QQ群:128659835 請註明“讀者”

第 30 章 Networking 網絡管理

目錄

30.1. hosts
30.1.1. /etc/hostname
30.1.2. hostnamectl - Control the system hostname
30.1.3. /etc/host.conf
30.1.4. /etc/hosts
30.1.5. hosts.allow / hosts.deny
30.1.6. /etc/resolv.conf
30.2. Network adapter 網絡適配器
30.2.1. 介面名稱
30.3. Ethernet Interfaces 乙太網介面
30.3.1. ifquery
30.3.2. DHCP
30.3.3. CentOS
30.3.4. Ubuntu
30.4. Gateway 設置預設網關
30.4.1. CentOS
30.5. 配置 DNS
30.5.1. 常規 DNS 配置 /etc/resolv.conf
30.5.2. 安全 DNS 配置
30.5.2.1. 啟用 DNS over TLS
30.5.2.2. 啟用 DNSSEC
30.5.2.3. 同時啟用 DNS over TLS 和 DNSSEC
30.5.2.4. 配置 NetworkManager
30.6. IP forwarding(IP轉發)
30.7. bonding
30.7.1. bonding
30.7.2. Ubuntu
30.8. brctl
30.9. Wireless - WiFi 配置
30.9.1. rfkill - tool for enabling and disabling wireless devices
30.9.2. iwlist - Get more detailed wireless information from a wireless interface
30.9.3. iwconfig - configure a wireless network interface
30.9.4. /proc/net/wireless
30.10. CentOS 8
30.10.1. nmtui - Text User Interface for controlling NetworkManager
30.10.2. nmcli - command-line tool for controlling NetworkManager
30.10.2.1. 查看連接狀態
30.10.2.2. 查看介面狀態
30.10.2.3. 添加介面
30.10.2.4.
30.10.2.5. 停止介面
30.10.2.6.
30.10.2.7. 顯示設備信息
30.11. 網絡檢查命令
30.11.1. ping
30.11.2. Finding optimal MTU
30.11.3. ss - another utility to investigate sockets
30.12. Ubuntu netplan (Ubuntu 18.04 之後才用 netplan 管理網絡)
30.13. Linux IP And Router
30.13.1. netmask
30.13.1.1. iptab
30.13.1.2. netmask - a netmask generation and conversion program
30.13.2. arp - manipulate the system ARP cache
30.13.2.1. display hosts
30.13.2.2. delete a specified entry
30.13.2.3. /proc/net/arp
30.13.2.4. /etc/ethers
30.13.3. iproute2
30.13.3.1.
30.13.3.2. 添加路由
30.13.3.3. 刪除路由
30.13.3.4. 變更路由
30.13.3.5. 替換已有的路由
30.13.3.6. 增加預設路由
30.13.3.7. cache
30.13.4. 策略路由
30.13.5. 負載均衡
30.13.6. MASQUERADE
30.13.7. ip tunnel
30.13.8. VLAN
30.13.9. Zebra

30.1. hosts

		
# cat -n /etc/hosts
     1  # Do not remove the following line, or various programs
     2  # that require network functionality will fail.
     3  127.0.0.1               development.domain.org development netkiller.localdomain netkiller
     4  ::1             localhost6.localdomain6 localhost6

		
		

30.1.1. /etc/hostname

# cat /etc/hostname
web1.example.com
			

查看IP地址

			
[root@localhost ~]# hostname --ip-address
::1 127.0.0.1			
			
			

30.1.2. hostnamectl - Control the system hostname

[root@netkiller ~]# hostnamectl
   Static hostname: netkiller.localdomain
         Icon name: computer-desktop
           Chassis: desktop
        Machine ID: 072e88a0fdd2447296554f3cd5129076
           Boot ID: a978056f50544355abd723b328a89b6f
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-229.el7.x86_64
      Architecture: x86_64
			

設置 hostname

			
[root@netkiller ~]# hostnamectl set-hostname master
			
			

30.1.3. /etc/host.conf

解析順序配置檔案

[root@development bin]# cat /etc/host.conf
order hosts,bind
			

首先在/etc/hosts檔案中尋找,如果不存在,再去DNS伺服器中尋找

30.1.4. /etc/hosts

IP地址後面TAB符,然後寫主機地址

127.0.0.1       localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
192.168.1.10	development.example.com development
			

30.1.5. hosts.allow / hosts.deny

/etc/hosts.allow 和 /etc/hosts.deny

許可IP/禁止IP,相當於黑白名單

30.1.6. /etc/resolv.conf

			
search example.com
nameserver 208.67.222.222
nameserver 208.67.220.220