系统操作者对字符敏感
系统网络通信需要通过ip地址这个数字
当操作者输入网址www.baidu.com,这个网址不是一个可以通信的IP地址
于是必须要在系统中把www.baidu.com变成百度服务器的IP地址
这样的过程叫做地址解析
DNS服务器:domain name server == 域名解析服务 ##解析就是把域名变成IP
vim /etc/resolv.conf ##dns的指向文件 不需要重新启动网络立即生效
nameserver 114.114.114.114 ##当需要某个域名的IP地址时去问 114.114.114.114
nameserver 8.8.8.8 ##问谷歌的ip
vim /etc/sysconfig/network-scripts/ifcfg-xxxx
DNS1=114.114.114.114 ##需要重启网络,当网络重新启动
此参数会修改/etc/resolv.conf
vim /etc/hosts ##本地解析文件,此文件中直接提供地址解析
系统默认:
/etc/hosts > /etc/resolv.conf
vim /etc/nsswitch.conf 39 hosts: files dns ##/etc/hosts优先
vim /etc/nsswitch.conf 39 hosts: dns files ##/etc/resolv.conf dns指向优
实验环境:
在Horizon_carry单网卡主机中:
ens160:172.25.254.10 #不可ping通
在carry双网卡主机中
先生成桥接网卡ens224
ens160:172.25.254.20
ens224:192.168.0.20 #可以ping 通
[root@carry ~]# systemctl start firewalld #打开火墙
[root@carry ~]# firewall-cmd --add-masquerade #临时地址伪装功能
success
[root@carry ~]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens160 ens224
sources:
services: cockpit dhcpv6-client ssh
ports:
protocols:
masquerade: yes <<<地址伪装功能开启,真实主机变成路由器
forward-ports:
source-ports:
icmp-blocks:
rich rules:
[root@carry ~]# sysctl -a | grep ip_forward #过滤一遍
net.ipv4.ip_forward = 1 #地址伪装功能开启
net.ipv4.ip_forward_use_pmtu = 0
[root@carry ~]# vim /etc/sysctl.conf
sysctl settings are defined through files in
/usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
Vendors settings live in /usr/lib/sysctl.d/.
To override a whole file, create a new file with the same in
/etc/sysctl.d/ and put new settings there. To override
only specific settings, add a file with a lexically later
name in /etc/sysctl.d/ and put new settings there.
For more information, see sysctl.conf(5) and sysctl.d(5).
net.ipv4.ip_forward=1
[root@carry ~]# sysctl -p
net.ipv4.ip_forward = 1