Ubuntu 设置静态IP上网

今天在无线网络下,虚拟中的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

重启电脑

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值