天天看点

Ubuntu 网速

最近对这个东西很头疼,Linux 下的网速一直很慢,而且每次开机都要重新加载网卡,手动连接网络,已经郁闷很久了,现在来研究一下这个东西!

1、Ethernet Interfaces

  Ethernet interfaces are identified by the system using the naming convention of ethX, where X represents a numeric value. The first Ethernet interface is typically identified as eth0, the second as eth1, and all others should move up in numerical order.

2、dentify Ethernet Interfaces

  To quickly identify all available Ethernet interfaces, you can use the ifconfig command as shown below.

3、Ethernet Interface Settings

  3.1、<code>/etc/network/interfaces</code>.

  The following is an example of how the interface identified as eth0 could be permanently configured with a port speed of 1000Mb/s running in full duplex mode.

4、/etc/resolv.conf

    DNS servers

首先,通过命令 : ifconfig -a 查看系统的网卡 一般的是:eth0 和 lo 分别是以太网的第一块网卡和用于本地回路测试的网卡.

对于eth0 有如下可以设置的方式:

1. 以DHCP方式配置网卡

编辑文件/etc/network/interfaces:

sudo vi /etc/network/interfaces

并用下面的行来替换有关eth0的行:

# The primary network interface - use DHCP to find our address

auto eth0

iface eth0 inet dhcp

用下面的命令使网络设置生效:

sudo /etc/init.d/networking restart

当然,也可以在命令行下直接输入下面的命令来获取地址

sudo dhclient eth0

2. 为网卡配置静态IP地址

# The primary network interface

iface eth0 inet static

address 192.168.3.90

gateway 192.168.3.1

netmask 255.255.255.0

network 192.168.3.0

broadcast 192.168.3.255

将上面的ip地址等信息换成你自己就可以了.

3. 设定第二个IP地址(虚拟IP地址)

在该文件中添加如下的行:

auto eth0:1

iface eth0:1 inet static

address 192.168.1.60

network x.x.x.x

broadcast x.x.x.x

gateway x.x.x.x

根据你的情况填上所有诸如address,netmask,network,broadcast和gateway等信息. 

4. 设置主机名称(hostname)

使用下面的命令来查看当前主机的主机名称:

sudo /bin/hostname

使用下面的命令来设置当前主机的主机名称:

sudo /bin/hostname newname

系统启动时,它会从/etc/hostname来读取主机的名称.

关于设置主机名称的更多信息, 可以用man 命令来查看hostname的更多详细信息:

(注意了: 该hostname既是命令又是文件的, man hostname 会得到我们想要的内容吗? 答案是否定的,

得到是命令hostname的manual手册,可以通过如下方式获得hostname脚本文件的格式)

5. 配置DNS

首先,你可以在/etc/hosts中加入一些主机名称和这些主机名称对应的IP地址,这是简单使用本机的静态查询.

要访问DNS 服务器来进行查询,需要设置/etc/resolv.conf文件. 

假设DNS服务器的IP地址是8.8.8.8, 那么/etc/resolv.conf文件的内容应为:

search google.com

nameserver  8.8.8.8

好了,文件基本配置好了:使用  sudo /etc/init.d/networking start 使其生效!  ( sudo ifup -a 也可是  /etc/network/interfaces 文件生效) 

使用ifconfig -a  看一下是不是你在 /etc/network/interfaces 脚本文件中指定地址

最后用ping命令测试一下你网络吧: ping www.baidu.com     

上一篇: ubuntu 更新
下一篇: hadoop ubuntu