RE:curl 命令和 php curl 访问网络地址时间长修改dns

技术分享 2019-10-01 00:00:00
注意:优先配置 /etc/sysconfig/network-scripts/ifcfg-eth0 因为在网络初始化时候他会覆盖 /etc/resolv.conf

$ sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
DNS1=8.8.8.8
DNS2=8.8.4.4
The DNS servers specified with "DNS1/DNS2" directives will then automatically be added to /etc/resolv.conf when the interface is activated. So there is no need to modify /etc/resolv.conf yourself.

The above two methods can be applied similarly to a static IP address case. That is:

DEVICE=eth0
BOOTPROTO=manual
ONBOOT=yes
IPADDR=10.0.1.27
NETWORK=10.0.1.0
NETMASK=255.255.255.0
PEERDNS=no (then add DNS to /etc/resolv.conf)
Or:

DEVICE=eth0
BOOTPROTO=manual
ONBOOT=yes
IPADDR=10.0.1.27
NETWORK=10.0.1.0
NETMASK=255.255.255.0
DNS1=8.8.8.8
DNS2=8.8.4.4
咨询小瓶科技
咨询我们
顶部