现在的位置: 首页 > 综合 > 正文

Ubuntu 设置静态IP上网

2013年01月19日 ⁄ 综合 ⁄ 共 1545字 ⁄ 字号 评论关闭

今天在无线网络下,虚拟中的Ubuntu无法上网,解决方法如下,仅供参考:

无线网络下,Virtual Box设置2个网卡,网卡1:NAT、网卡2:Bridge 连接,vi  /etc/network/interfaces

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet static
address 192.168.1.162  #设置eth1为静态ip,先查看主机ip地址,在同一网段设置此虚拟机ip
netmask 255.255.255.0
gateway 192.168.1.1

重启网络 /etc/init.d/networking restart

======================================================================

1.如果是物理机是通过有线上网,那么需要使用NAT网络连接方式,如果是无线网络,那么需要使用桥接方式上网

对于桥接方式,需要把虚拟机的网关设置为物理机的网关:

1)vi /etc/network/interfaces

2)重启网络 /etc/init.d/networking restart

如果还是不行,比如ping www.baidu.com ,报:

ping: unknown host www.baidu.com

这时可以使用googl的公共DNScat /etc/resolv.conf
-------------------------------------------------------------------
nameserver 8.8.8.8
nameserver 8.8.4.4

=========================================================================

Ubuntu Network Error: Ignoring unknown interface eth0=eth0

When I ran "/sbin/ifup", or "/sbin/ifdown", or "/etc/init.d/networking restart", I got some error message like

Ignoring unknown interface eth0=eth0.
Ignoring unknown interface eth1=eth1.
Ignoring unknown interface eth2=eth2.
Ignoring unknown interface ath0=ath0.
Ignoring unknown interface wlan0=wlan0.

Note that I do have eth0, and "ifconfig" shows that it is up and has been assigned an IP.

To fix the error, check the file /etc/network/interfaces, comment out the unwanted interfaces, and keep at least the following:

auto lo
iface lo inet loopback

auto eth0

iface eth0 inet dhcp

=============================================

设置静态IP的方法

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet static
address 192.168.1.162  #设置eth1为静态ip
netmask 255.255.255.0
gateway 192.168.1.1

重启电脑

抱歉!评论已关闭.