Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 14 章 Networking 网络管理

目录

14.1. hosts
14.1.1. /etc/hostname
14.1.2. /etc/host.conf
14.1.3. /etc/hosts
14.1.4. hosts.allow / hosts.deny
14.1.5. /etc/resolv.conf
14.2. Network adapter 网络适配器
14.2.1. 接口名称
14.3. CentOS 8 Stream
14.3.1. hostnamectl - Control the system hostname
14.3.2. nmtui - Text User Interface for controlling NetworkManager
14.3.3. nmcli - command-line tool for controlling NetworkManager
14.4. Ubuntu netplan (Ubuntu 18.04 之后才用 netplan 管理网络)
14.4.1. DHCP
14.4.2. 静态IP地址
14.5. Gateway 设置默认网关
14.6. 配置 DNS
14.6.1. 常规 DNS 配置 /etc/resolv.conf
14.6.2. 安全 DNS 配置
14.7. IP forwarding(IP转发)
14.8. bonding
14.8.1. bonding
14.8.2. Ubuntu
14.9. Wireless - WiFi 配置
14.9.1. rfkill - tool for enabling and disabling wireless devices
14.9.2. iwlist - Get more detailed wireless information from a wireless interface
14.9.3. iwconfig - configure a wireless network interface
14.9.4. /proc/net/wireless
14.10. Linux IP And Router
14.10.1. IP 地址类别
14.10.2. ping
14.10.3. Finding optimal MTU
14.10.4. ss - another utility to investigate sockets
14.10.5. netmask 子网掩码
14.10.6. arp - manipulate the system ARP cache
14.10.7. iproute2
14.10.8. VLAN
14.10.9. 网桥
14.10.10. Zebra
14.11. IPv6
14.11.1. 禁用 IPv6
14.11.2. Ipv6 无法连接
14.12. 早期版本
14.12.1. 早期 Ubuntu
14.12.2. CentOS 6

14.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

		
		

14.1.1. /etc/hostname

# cat /etc/hostname
web1.example.com
			

查看IP地址

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

14.1.2. /etc/host.conf

解析顺序配置文件

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

首先在/etc/hosts文件中寻找,如果不存在,再去DNS服务器中寻找

14.1.3. /etc/hosts

IP地址后面TAB符,然后写主机地址

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

14.1.4. hosts.allow / hosts.deny

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

许可IP/禁止IP,相当于黑白名单

14.1.5. /etc/resolv.conf

			
search example.com
nameserver 208.67.222.222
nameserver 208.67.220.220