`
494078416
  • 浏览: 81640 次
  • 性别: Icon_minigender_1
  • 来自: 青岛
社区版块
存档分类
最新评论

解决ubuntu下firefox上网慢的问题

阅读更多

firefox上网慢是由于解析域名需要太长时间造成的,解决办法如下:

在ubuntu上通过建立本地的dns缓存来提高网络浏览速度


(有关软件运作原理方面我就不翻译了,有些我也不是很懂,感兴趣的朋友可以读一下原文)
dns服务器使用来把域名解析成ip地址的。例如,当你想要访问yahoo.com时,dns服务器找到这个域的地址,并把你的请求发到正确的方向。
你也可以在自己的机器上设置一个dns缓存,这会加速寻找域名的过程。这大约会有30~60毫秒的差别。
再乘上这一天你要访问网页的总数量来估计一下这个速度的提升。

在ubuntu上安装dnsmasq

用下面命令安装dnsmasq
sudo apt-get install dnsmasq

在/etc/dnsmasq.conf 中找到
#listen-address
并改成
listen-address=127.0.0.1

接下来编辑文件 /etc/dhcp3/dhclient.conf
确保其中某一部分与下面的一段完全相同,特别是有着 “prepend domain-name-servers 127.0.0.1;”的一行

#supersede domain-name “fugue.com home.vix.com”;
prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name,
netbios-name-servers, netbios-scope;

接下来打开文件 /etc/resolv.conf
in your text editor. It probably looks like:
在你的文字编辑器里出现像下面的文字:

nameserver 217.54.170.023
nameserver 217.54.170.024
nameserver 217.54.170.026

将nameserver 127.0.0.1 加到最前面,改成下面的样子

nameserver 127.0.0.1
nameserver 217.54.170.023
nameserver 217.54.170.024
nameserver 217.54.170.026

现在你需要用下面的命令重新启动dnsmasq
sudo /etc/init.d/dnsmasq restart.
现在你就有了一个本地的dns缓存


测试一下你的本地缓存
If you want to measure your speed improvement, type the command
如果你想确认你有速度上的提升,输入如下命令:
dig yahoo.com
你会发现如下字样 “;; Query time: 38 msec”
然后再次输入,又会变成:”;; Query time: 2 msec”


英文原文如下:

Local DNS Cache for Faster Browsing on Ubuntu System

by @ 8:57 am. Filed under Other Linux

A DNS server resolves domain names into IP addresses . So when you request “yahoo.com” for example, the DNS server finds out the address for the domain, and sends your request the right way.

 

You can run a DNS cache on your computer . This will speed up the process of looking up domain names when browsing. The difference is about 30-60 ms. Multiply that difference by the number of websites you visit a day for an approximate estimate of the speed improvement.

The following instructions are for someone with a broadband internet connection , where the computer gets it’s local IP address using DHCP from the router in your home or office.

Install dnsmasq in Ubuntu

Dnsmasq is a lightweight, easy to configure, DNS forwarder and DHCP server . It is designed to provide DNS and optionally, DHCP, to a small network. It can serve the names of local machines which are not in the global DNS. The DHCP server integrates with the DNS server and allows machines with DHCP-allocated addresses to appear in the DNS with names configured either in each host or in a central configuration file. Dnsmasq supports static and dynamic DHCP leases and BOOTP for network booting of diskless machines.

First you need to make sure that Universe repository is enabled in your sources.list file

Install dnsmasq Using the following command

sudo apt-get install dnsmasq

uncomment the following line (remove “#” in the beginning) in the file /etc/dnsmasq.conf

listen-address=127.0.0.1

Now edit

/etc/dhcp3/dhclient.conf

and make sure the section below exactly like this, especially the line that says “prepend domain-name-servers 127.0.0.1;”

#supersede domain-name “fugue.com home.vix.com”;
prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name,
netbios-name-servers , netbios-scope;

In the normal case, when you get a new dhcp lease, the dhcp3 client (tool) on your computer gets a new lease, and updates the

/etc/resolv.conf

file on your computer with the right values for the DNS servers to use (usually some machine in the network of your hosting provider ). Adding the “prepend” option as we did above ensures that “127.0.0.1″ will appear on the top of the list of DNS servers. That magic number refers to your own computer. So in the future, whenever your computer needs to resolve a domain name, it will forward that request to dnsmasq (which is running at 127.0.0.1 - your computer). If the details for the domain name are already in you cache, well and good, dnsmasq will serve it up and make the process real fast. If it is not in the cache, then dnsmasq will look at the /etc/resolv.conf file and use the nameservers listed below the “127.0.0.1″. I hope that explains things.

Now open the file

/etc/resolv.conf

in your text editor. It probably looks like:

search yourisp.com
nameserver 217.54.170.023
nameserver 217.54.170.024
nameserver 217.54.170.026

The 127.0.0.1 is missing right now since you haven’t renewed your lease after you edited the /etc/dhcp3/dhclient.conf file. So, let us add that in manually this one time. After you do, your /etc/resolv.conf file will look like the following:

search yourisp.com
nameserver 127.0.0.1
nameserver 217.54.170.023
nameserver 217.54.170.024
nameserver 217.54.170.026

Now you need to restart the dnsmasq using the following command

sudo /etc/init.d/dnsmasq restart.

Now you are running a local DNS cache.

Testing Your Local DNS Cache

If you want to measure your speed improvement, type the command

dig yahoo.com

You will see something like “;; Query time: 38 msec” there.

Now type the command again, and you should see something like:”;; Query time: 2 msec”

分享到:
评论

相关推荐

    Ubuntu安装指南.zip

    - 安装常用软件:使用内置的“软件中心”或通过命令行安装常用软件,如办公套件LibreOffice、浏览器Firefox、媒体播放器VLC等。 - 配置网络:设置无线网络连接,确保能正常上网。对于有线连接,Ubuntu通常能自动...

    ubuntu8.04速成手册1.0.pdf

    7. **网络与互联网**:手册会介绍如何配置网络连接,包括有线、无线和拨号上网,以及如何使用Firefox浏览器浏览网页、发送电子邮件和使用即时通讯工具。 8. **办公软件与多媒体**:Ubuntu 8.04预装了LibreOffice...

    ubutu系统下如何上网

    本文将详细介绍如何在Ubuntu系统下设置上网,包括手动添加PPPOE拨号连接以及解决浏览网页时遇到的Flash插件问题。 首先,针对PPPOE拨号上网的设置,Ubuntu提供了一个便捷的工具`pppoeconf`。在终端中输入`sudo ...

    1604安装问题.odt_install_ubuntu1604_

    5. 安装常用软件:如办公套件LibreOffice(`sudo apt install libreoffice`)、浏览器Firefox(`sudo apt install firefox`)等。 6. 安全设置:创建一个非root用户,禁用root账户登录,启用防火墙`ufw`,并安装...

    ubuntu用户手册

    它提供了丰富的预装软件,如OpenOffice套件(包括文字处理、电子表格和演示文稿工具,分别对应于Word、Excel和PowerPoint),GIMP图像编辑器(类似于Photoshop),Firefox浏览器,Pidgin聊天软件(支持多种即时通讯...

    Wubi安装Ubuntu

    可以使用ping命令检查网络连接,通过Firefox浏览网页。如需安装QQ,可以在终端中使用sudo apt-get install命令,或者下载Linux版QQ进行安装。 6. 如果没有预先安装语言包,可以在桌面环境中通过“system”->...

    ubuntu linux版本的安装和配置,使用

    ### Ubuntu Linux 版本的安装和配置及使用 #### Ubuntu Linux 的扼要介绍 Ubuntu 是一个基于 Debian 的 Linux 发行版,以其用户友好性、稳定性以及广泛的社区支持而闻名。Ubuntu 不仅适用于个人电脑(PC)和服务器...

    Ubuntu10.04入门教程PDF.rar

    10. **故障排查与社区支持**:介绍如何查找和解决常见问题,如何利用Ubuntu论坛、AskUbuntu网站和官方文档获取帮助。 这本教程对于初学者而言是一份宝贵的资源,通过它,你可以系统地学习Ubuntu 10.04的各个方面,...

    Ubuntu入门教程

    7. **多媒体和互联网**: 教导如何播放音频和视频文件,使用Rhythmbox或VLC媒体播放器,以及如何使用Firefox或Chromium等浏览器上网。 8. **办公软件**: 引导用户熟悉LibreOffice套件,包括Writer(文字处理)、Calc...

    虚拟机ubuntu16.04无法连网的解决方法

    刚安装玩Ubuntu,打开后上网没有网络连接 ,点击右上角的数据连接,显示已经启动联网,但是用火狐还是无法上网。 解决方法如下:  先查看虚拟机的网络适配器:点击虚拟机左上角的编辑,里面有个网络适配器 然后再...

    Ubuntu Linux 9.04 正式版 光盘安装教程+安装后配置教程.doc

    - 安装必要的软件,如办公套件LibreOffice、浏览器Firefox等,可以通过`sudo apt-get install 软件名`命令完成。 - 配置网络连接,确保能够上网。如果使用无线网络,可能需要额外安装驱动或使用软件设置无线连接。...

    第一次安装Ubuntu该怎么对系统进行配置?.docx

    - 安装过程中可能会遇到依赖问题,解决方法是通过终端命令`sudo apt-get update`来更新软件包列表。 - 更新后重新尝试安装搜狗输入法。 #### 九、输入法设置完成 - **完成设置**: - 设置完成后,需要重启或...

    笨兔兔的故事

    内容涵盖连接无线和有线网络,设置网络共享,以及使用Firefox或其他浏览器上网。此外,还会讲解邮件客户端、即时通讯工具和云服务的使用,以便用户能更好地进行远程协作和通信。 第五章主要关注系统维护和故障排查...

    使用VMware10安装Ubuntu 14步骤图文详解

    安装完成后,你将看到Ubuntu的桌面环境,可以启动预装的Firefox浏览器进行上网,标志着Ubuntu 14.04已经在VMware 10中成功安装。 总结来说,使用VMware 10安装Ubuntu 14.04是一个相对简单的过程,只需遵循上述步骤...

    The story of bentutu.pdf(笨兔兔的故事)

    在操作层面,作者通过主人公使用Firefox(狐狸妹妹)上网查找软件源的操作,展示了Linux系统下软件的安装和管理。Ubuntu使用了包管理器,如APT(Advanced Package Tool),来安装、更新和管理软件包。通过包管理器,...

    ubuntn 快速入门指南

    - **使用Firefox Web浏览器**:Firefox是一款流行的Web浏览器,用户可以利用其分页浏览、书签等功能来进行高效上网。 #### 六、高级功能 - **添加和删除应用程序**:用户可以通过系统自带的应用商店来安装或卸载...

    轻松配置VOLANS

    2. **打开浏览器**:在任意支持的浏览器(如Chrome、Firefox、Edge等)中输入192.168.0.1,这将打开路由器的管理界面。 3. **登录**:输入默认的用户名“admin”和密码“admin”。如之前所述,首次登录后,请务必...

    手册 (4b)-已转换.pdf

    对于操作系统支持,树莓派拥有多样化的系统选择,如NOOBS、Raspbian、Ubuntu Mate、Snappy Ubuntu Core、Windows 10 IoT、OSMC、RISC OS、Raspbmc/Kodi、OpenELEC、Arch Linux ARM、Pidora、Firefox OS、Kali Linux...

Global site tag (gtag.js) - Google Analytics