Home | 简体中文 | 繁体中文 | 杂文 | 知乎专栏 | Github | OSChina 博客 | 云社区 | 云栖社区 | Facebook | Linkedin | 视频教程 | 打赏(Donations) | About
知乎专栏多维度架构

第 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. Hostname
30.3. Network adapter 网络适配器
30.3.1. 接口名称
30.4. Ethernet Interfaces 以太网接口
30.4.1. ifquery
30.4.2. DHCP
30.4.3. Static IP
30.5. Mask 子网掩码
30.6. Gateway 设置默认网关
30.7. Configuring Name Server Lookups
30.8. IP forwarding(IP转发)
30.9. bonding
30.9.1. Ubuntu
30.10. Wireless - WiFi 配置
30.10.1. rfkill - tool for enabling and disabling wireless devices
30.10.2. iwlist - Get more detailed wireless information from a wireless interface
30.10.3. iwconfig - configure a wireless network interface
30.10.4. /proc/net/wireless
30.11. CentOS 网络配置
30.11.1. Gateway
30.11.2. bonding
30.11.3. brctl
30.12. 网络检查命令
30.12.1. ping
30.12.2. Finding optimal MTU
30.12.3. ss - another utility to investigate sockets
30.13. Ubuntu netplan (Ubuntu 18.04 之后才用 netplan 管理网络)
30.14. Linux IP And Router
30.14.1. netmask
30.14.1.1. iptab
30.14.1.2. netmask - a netmask generation and conversion program
30.14.2. arp - manipulate the system ARP cache
30.14.2.1. display hosts
30.14.2.2. delete a specified entry
30.14.2.3. /proc/net/arp
30.14.2.4. /etc/ethers
30.14.3. iproute2
30.14.3.1.
30.14.3.2. 添加路由
30.14.3.3. 删除路由
30.14.3.4. 变更路由
30.14.3.5. 替换已有的路由
30.14.3.6. 增加默认路由
30.14.3.7. cache
30.14.4. 策略路由
30.14.5. 负载均衡
30.14.6. MASQUERADE
30.14.7. ip tunnel
30.14.8. VLAN
30.14.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