我正在努力在托管云环境中建立 CentOS-8 机器,作为将我公司的运营从本地机器迁移出来的一部分。我需要向此脚本定义的接口添加 2 个别名 IP 地址。
[root@XXXXXXXX network-scripts]# cat ifcfg-ens192
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens192
UUID=e10ccada-6834-4f7f-b415-78e2d0b61e76
DEVICE=ens192
ONBOOT=yes
IPADDR=10.1.0.25
PREFIX=24
GATEWAY=10.1.0.1
DNS1=66.129.64.228
IPV6_PRIVACY=no
DNS2=66.129.96.228
[root@XXXXXXXX network-scripts]#
编辑后,我有这个。
[root@XXXXXXXX network-scripts]# cat ifcfg-ens192
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens192
UUID=e10ccada-6834-4f7f-b415-78e2d0b61e76
DEVICE=ens192
ONBOOT=yes
IPADDR0=10.1.0.25
IPADDR1=10.1.0.20
IPADDR2=10.1.0.76
PREFIX=24
GATEWAY=10.1.0.1
DNS1=66.129.64.228
IPV6_PRIVACY=no
DNS2=66.129.96.228
[root@XXXXXXXX network-scripts]#
重新启动机器后,我发现 DNS 无法正常工作。
[root@XXXXXXXX network-scripts]# ping google.com
ping: google.com: Name or service not known
[root@XXXXXXXX network-scripts]# ping 66.129.64.228
connect: Network is unreachable
[root@XXXXXXXX network-scripts]# ping 66.129.96.228
connect: Network is unreachable
[root@XXXXXXXX network-scripts]#
和 ip addr 显示以下内容。
[root@XXXXXXXX network-scripts]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:50:56:af:4f:5c brd ff:ff:ff:ff:ff:ff
inet 10.1.0.25/8 brd 10.255.255.255 scope global noprefixroute ens192
valid_lft forever preferred_lft forever
inet 10.1.0.20/8 brd 10.255.255.255 scope global secondary noprefixroute ens192
valid_lft forever preferred_lft forever
inet 10.1.0.76/8 brd 10.255.255.255 scope global secondary noprefixroute ens192
valid_lft forever preferred_lft forever
inet6 fe80::6a22:319:a718:3d5b/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:7f:16:df brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:7f:16:df brd ff:ff:ff:ff:ff:ff
[root@XXXXXXXX network-scripts]#
看起来这不是真正的 DNS 问题,而是 ifcfg 脚本问题,我不知道如何更正脚本。