zoukankan      html  css  js  c++  java
  • Ubuntu 设置静态IP上网 分类: ubuntu 20130511 11:18 693人阅读 评论(0) 收藏

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

    重启电脑

  • 相关阅读:
    鲸云效总结自动化测试常见问题
    鲸云效解析自动化测试前期的准备很重要
    鲸云效为小程序上线做兼容性审核
    ADO.NET删除和修改
    GIT常用操作命令
    随笔
    你应该知道的计算机延迟数字
    centos安装dotnet-sdk-3.1出现no package问题
    Linux CentOS7.9安装Docker
    CentOS6.8配置IP
  • 原文地址:https://www.cnblogs.com/think1988/p/4628201.html
Copyright © 2011-2022 走看看