ubuntu网络设置

来源:互联网 发布:mpu6050单片机电路图 编辑:程序博客网 时间:2024/05/01 15:36

pip install 总是出现pip connection failure: cannot fetch index base URL http://pypi.python.org/simple/,造成安装不了软件包,真的很头疼。。。。

找了一圈问题,发现连eth0网卡都没有,网络根本就不连通,网站也上不了

问题一. ifconfig之后只显示lo,没有看到eth0

问题二. ifconfig之后显示eth0,但是没有显示静态IP地址,即无inet、地址、广播、掩码。

问题三. ping命令不能使用,因为dns还没设置,编辑/etc/resolv.conf,加上dns服务器地址。

问题一:ifconfig之后只显示lo,没有看到eth0 ?

eth0设置不正确,导致无法正常启动,修改eth0配置文件就好
ubuntu 12.04的网络设置文件是/etc/network/interfaces,打开文件,会看到
auto lo
iface lo inet loopback
这边的设置是本地回路。在后面加上
auto eth0
iface eth0 inet static
address 192.168.1.230 //(ip地址)
netmask 255.255.255.0 //(子网掩码)
gateway 192.168.1.1 //(网关)
其中eth0就是电脑的网卡,如果电脑有多块网卡,比如还会有eth1,都可以在这里进行设置。iface eth0 inet 设置为dhcp是动态获取IP,设置为static则用自定义的IP。
一般就设置成iface eth0 inet dhcp(推荐)

auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp

然后输入命令行:ifconfig eth0 up #开启eth0

问题二:ifconfig之后显示eth0,但是没有显示“inet/地址/广播/掩码/ ”?

先用sudo dhclient eth0更新IP地址
然后运行sudo ifconfig eth0

3.reboot

问题三:重启后,ping命令不能使用,因为dns还没设置,编辑/etc/resolv.conf,加上dns服务器地址。

设置好后,如果直接ping www.baidu.com会发现ping不通,因为dns还没设置,编辑/etc/resolv.conf,加上dns服务器地址。
nameserver 8.8.8.8
nameserver 8.8.4.4
这两个是Google提供的免费DNS服务器的IP地址

原创粉丝点击