这篇文章以squid使用时的错误问题对应为例,介绍一下squid上设定DNS的方法。

目录

  • 现象
  • 错误原因
  • 设定方法
  • 重启squid服务
  • 结果确认
  • 总结

现象

liumiaocn:~ liumiao$ export https_proxy=http://192.168.31.242:3128
liumiaocn:~ liumiao$ curl http://www.baidu.com
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta type="copyright" content="Copyright (C) 1996-2020 The Squid Software Foundation and contributors">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>ERROR: The requested URL could not be retrieved</title>
<style type="text/css"><!-- /** Copyright (C) 1996-2020 The Squid Software Foundation and contributors** Squid software is distributed under GPLv2+ license and includes* contributions from numerous individuals and organizations.* Please see the COPYING and CONTRIBUTORS files for details.*//*Stylesheet for Squid Error pagesAdapted from design by Free CSS Templateshttp://www.freecsstemplates.orgReleased for free under a Creative Commons Attribution 2.5 License
*//* Page basics */
* {font-family: verdana, sans-serif;
}html body {margin: 0;padding: 0;background: #efefef;font-size: 12px;color: #1e1e1e;
}/* Page displayed title area */
#titles {margin-left: 15px;padding: 10px;padding-left: 100px;background: url('/squid-internal-static/icons/SN.png') no-repeat left;
}/* initial title */
#titles h1 {color: #000000;
}
#titles h2 {color: #000000;
}/* special event: FTP success page titles */
#titles ftpsuccess {background-color:#00ff00;width:100%;
}/* Page displayed body content area */
#content {padding: 10px;background: #ffffff;
}/* General text */
p {
}/* error brief description */
#error p {
}/* some data which may have caused the problem */
#data {
}/* the error message received from the system or other software */
#sysmsg {
}pre {
}/* special event: FTP / Gopher directory listing */
#dirmsg {font-family: courier, monospace;color: black;font-size: 10pt;
}
#dirlisting {margin-left: 2%;margin-right: 2%;
}
#dirlisting tr.entry td.icon,td.filename,td.size,td.date {border-bottom: groove;
}
#dirlisting td.size {width: 50px;text-align: right;padding-right: 5px;
}/* horizontal lines */
hr {margin: 0;
}/* page displayed footer area */
#footer {font-size: 9px;padding-left: 10px;
}body
:lang(fa) { direction: rtl; font-size: 100%; font-family: Tahoma, Roya, sans-serif; float: right; }
:lang(he) { direction: rtl; }--></style>
</head><body id=ERR_DNS_FAIL>
<div id="titles">
<h1>ERROR</h1>
<h2>The requested URL could not be retrieved</h2>
</div>
<hr><div id="content">
<p>The following error was encountered while trying to retrieve the URL: <a href="http://www.baidu.com/">http://www.baidu.com/</a></p><blockquote id="error">
<p><b>Unable to determine IP address from host name <q>www.baidu.com</q></b></p>
</blockquote><p>The DNS server returned:</p>
<blockquote id="data">
<pre>No DNS records</pre>
</blockquote><p>This means that the cache was not able to resolve the hostname presented in the URL. Check if the address is correct.</p><p>Your cache administrator is <a href="mailto:webmaster?subject=CacheErrorInfo%20-%20ERR_DNS_FAIL&amp;body=CacheHost%3A%20localhost%0D%0AErrPage%3A%20ERR_DNS_FAIL%0D%0AErr%3A%20%5Bnone%5D%0D%0ADNS%20ErrMsg%3A%20No%20DNS%20records%0D%0ATimeStamp%3A%20Wed,%2016%20Sep%202020%2013%3A03%3A39%20GMT%0D%0A%0D%0AClientIP%3A%20192.168.31.242%0D%0A%0D%0AHTTP%20Request%3A%0D%0AGET%20%2F%20HTTP%2F1.1%0AUser-Agent%3A%20curl%2F7.64.1%0D%0AAccept%3A%20*%2F*%0D%0AProxy-Connection%3A%20Keep-Alive%0D%0AHost%3A%20www.baidu.com%0D%0A%0D%0A%0D%0A">webmaster</a>.</p>
<br>
</div><hr>
<div id="footer">
<p>Generated Wed, 16 Sep 2020 13:03:39 GMT by localhost (squid/4.13)</p>
<!-- ERR_DNS_FAIL -->
</div>
</body></html>
liumiaocn:~ liumiao$

错误原因

错误信息提示的非常清楚:This means that the cache was not able to resolve the hostname presented in the URL. Check if the address is correct. 然后再看一下会看到如下错误信息:Unable to determine IP address from host name,所以典型的DNS错误,但是需要注意的是却不是操作系统的网络设定处的DNS设定


设定方法

在如下squid的配置文件中添加8.8.8.8 和 8.8.4.4作为dns服务器

liumiaocn:~ liumiao$ grep dns /usr/local/etc/squid.conf
liumiaocn:~ liumiao$ vi /usr/local/etc/squid.conf
liumiaocn:~ liumiao$ grep dns /usr/local/etc/squid.conf
dns_nameservers 8.8.8.8 8.8.4.4
liumiaocn:~ liumiao$

重启squid服务

liumiaocn:~ liumiao$ brew services restart squid
Stopping `squid`... (might take a while)
==> Successfully stopped `squid` (label: homebrew.mxcl.squid)
==> Successfully started `squid` (label: homebrew.mxcl.squid)
liumiaocn:~ liumiao$
liumiaocn:~ liumiao$ brew services list |grep squid
squid started liumiao /Users/liumiao/Library/LaunchAgents/homebrew.mxcl.squid.plist
liumiaocn:~ liumiao$

结果确认

liumiaocn:~ liumiao$ export https_proxy=http://192.168.31.242:3128
liumiaocn:~ liumiao$ curl http://www.baidu.com
<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>百度一下,你就知道</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus></span><span class="bg s_btn_wr"><input type=submit id=su value=百度一下 class="bg s_btn"></span> </form> </div> </div> <div id=u1> <a href=http://news.baidu.com name=tj_trnews class=mnav>新闻</a> <a href=http://www.hao123.com name=tj_trhao123 class=mnav>hao123</a> <a href=http://map.baidu.com name=tj_trmap class=mnav>地图</a> <a href=http://v.baidu.com name=tj_trvideo class=mnav>视频</a> <a href=http://tieba.baidu.com name=tj_trtieba class=mnav>贴吧</a> <noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&amp;tpl=mn&amp;u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>登录</a> </noscript> <script>document.write('<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === "" ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">登录</a>');</script> <a href=//www.baidu.com/more/ name=tj_briicon class=bri style="display: block;">更多产品</a> </div> </div> </div> <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>关于百度</a> <a href=http://ir.baidu.com>About Baidu</a> </p> <p id=cp>&copy;2017&nbsp;Baidu&nbsp;<a href=http://www.baidu.com/duty/>使用百度前必读</a>&nbsp; <a href=http://jianyi.baidu.com/ class=cp-feedback>意见反馈</a>&nbsp;京ICP证030173号&nbsp; <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>
liumiaocn:~ liumiao$

总结

在squid中添加dns的服务器即可解决squid中无法进行ip和域名更换的问题,实际在这一点上MacOS和Linux并无不同。

MacOS基础:代理服务器squid的DNS设定方法相关推荐

  1. GDB基础:MacOS上的GDB安装与设定

    这篇文章介绍一下MacOS下GDB的安装与设定方法.在MacOS上使用LLDB可能会更方便一些,但是对于习惯gdb的用于以及LLDB无法完成的地方,GDB还是有很多优势的. 目录 环境说明 安装与确认 ...

  2. MacOS(Catalina):SIP设定方法

    这篇文章以MacOS的Catalina版本为例介绍一下SIP的设定方法. SIP SIP 是System Integrity Protection(系统完整性保护)的缩写,在实际使用的时候会碰到暂时将 ...

  3. 【阿里妈妈数据科学系列】第五篇:实验指标设定方法与指标体系构建

    ▐ 前言 在[阿里妈妈数据科学系列]前四期内容中,我们介绍了 AB TEST 的基础知识与框架及每个部分的方法论与技术,本期我们主要介绍实验指标设定方法与指标体系构建. 指标体系构建在 AB Test ...

  4. mysql 重启_解决MYSQL死机,定时重启MYSQL,wdcp计划任务设定方法,

    首先,确认你的默认计划任务是否可以执行,并产生日志.如果默认计划任务也不执行的话,请执行以下命令 yum install -y crontabs vixie-cron 增加一个新的计划任务 以重启we ...

  5. 零基础学手绘插画的方法

    零基础学手绘插画的方法?插画要掌握的东西很多,因此可在练习过程中学习或试验不同的方法,当然这过程并不是漫无目的,而是每一次都有个主题,例如色彩的练习.氛围的尝试.构图的设计.留白的练习- 等等,甚至只 ...

  6. 计算机软硬件故障排除知识,计算机软硬件基础知识及常见故障排除方法(精选).doc...

    文档介绍: 计算机软硬件基础知识及常见故障排除方法 CPU的主频.外频和倍频3者的关系:主频=外频×倍频 计算机的主板一般有南北桥两片芯片,南桥芯片提供对键盘控制器.实时时钟控制器.USB.高级能源管 ...

  7. 理光有邮件服务器吗,理光Aficio 3035复印机通过电子邮件发送扫描文件的设定方法及操作步骤...

    [转]http://www.hi-office.cn/ricoh/maintenance/4987.html 理光Aficio 3035复印机通过电子邮件发送扫描文件的设定方法及操作步骤 作者:hio ...

  8. 在Ubuntu 14.04 64bit中永久添加DNS的方法

    DNS信息是由/etc/resolv.conf提供的,它是每次开机时,由/sbin/resolvconf生成的 /etc/resolv.conf是/run/resolvconf/resolv.conf ...

  9. 零基础快速学习Java技术的方法整理

    在学习java技术这条道路上,有很多都是零基础学员,他们对于java的学习有着很多的不解,不知怎么学习也不知道如何下手,其实Java编程涉及到的知识点还是非常多的,我们需要制定java学习路线图这样才 ...

最新文章

  1. 【王俊杰de人工智能实战课】第6次作业
  2. golang中的strings.Join
  3. css判断不同分辨率显示不同宽度布局实现自适应宽度
  4. Oracle_PL/SQL developer拷贝粘贴中文乱码问题
  5. [渝粤教育] 西南科技大学 西方现代派文学 在线考试复习资料
  6. 【Tensorflow】【损失函数】交叉熵数据验证(下)---BinaryCrossentropy二分类
  7. robocode 安装 使用
  8. 【资源分享】Go语言并发之道 [美] 凯瑟琳(Katherine Cox-Buday)著 PDF 下载
  9. MODIS数据批量下载
  10. python16_day14【jQuery】
  11. 用C语言实现传递闭包(warshall算法)
  12. 【数据可视化】三款主流开源数据可视化工具对比:Superset、DataEase、MetaBase
  13. 问的书写规则是什么意思_汉字笔顺的书写规则是什么
  14. ArcBlock 将作证支持美国华盛顿州区块链立法 | ABT 活动
  15. typecho与WordPress博客程序评测及推荐
  16. 蓝桥杯单片机(八)DS18B20温度测量(整数显示)
  17. filter java exclude_Filter中排除对指定URL的过滤
  18. 不允许一个用户使用一个以上用户名与服务器或共享资源的多重连接,中断与此服务器或共享资源的所有连接,然后再试一次
  19. 手札-11(京东实战手札)
  20. 怎么恢复计算机系统软件,重装系统后软件如何恢复原状

热门文章

  1. deepin/UOS自带浏览器安装插件
  2. 马蜂窝推荐排序算法模型是如何实现快速迭代的
  3. 北航宇航学院计算机,北航宇航学院模式识别与智能系统导师介绍:尹继豪
  4. 什么是gadget,以及64位libc如何泄露的问题
  5. C#与西门子PLC通信通过S7.NET
  6. 操作系统-进程管理实验(2)
  7. 百度地图api驾车出行方案_摄影操作教程:驾车出行的75个步骤
  8. python 气候_用Python下载美国国家气候数据中心(NCDC)的气候数据
  9. ProtoThreads在Arduino中的应用#多任务处理#
  10. layui 如何动态加载局部页面_从输入URL到页面加载的过程?如何由一道题完善自己的前端知识体系!...