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

    重启电脑

  • 相关阅读:
    雨天拍照技巧
    was8.5和aop的问题:JVMVRFY013 违反类装入约束o
    Docker Swarm
    Docker compose
    docker 网络
    dockerFile
    docker容器数据卷
    docker容器数据卷
    dokcer镜像详解
    Portainer可视化面板安装
  • 原文地址:https://www.cnblogs.com/think1988/p/4628201.html
Copyright © 2011-2022 走看看