• Ubantu和CentOS设置静态ip


    Ubantu设置ip:

    1、sudo vim /etc/NetworkManager/NetworkManager.conf

       将false改成true

    2、修改配置文件/etc/network/interfaces
    sudo vim /etc/network/interfaces
    添加以下内容:(具体ip根据nat下面的地址来配喔)
    auto eth0 //设置自动启动eth0接口
    iface eth0 inet static //配置静态IP
    address 192.168.66.106 //IP地址
    netmask 255.255.255.128 //子网掩码
    gateway 192.168.66.2  //网关和nat配置中要一致,下面的dns也得这样

    dns-nameservers 192.168.66.2

    3、重启网络,使配置生效:sudo /etc/init.d/networking restart
    4、重启机器:sudo shutdown -r now



    CentOS设置静态Ip:
    (设置前先把 NetworkManager 服务关掉,否则会自动帮你设置ip很烦 临时命令: service NetworkManager stop
    永久:
    chkconfig NetworkManager off
    1、root用户编辑ifcfg-eth0 
     vi /etc/sysconfig/network-scripts/ifcfg-eth0 
    修改内容如下:
    DEVICE=eth0
    BOOTPROTO=static
    ONBOOT=yes
    IPADDR=192.168.66.106
    GATEWAY=192.168.66.2
    NETMASK=255.255.255.0 
    DNS1=192.168.66.2    

    2、修改网关配置

         ① vi /etc/sysconfig/network

      (主机名也可以这样修改>$:hostname pissh

      

    NETWORKING=yes
    HOSTNAME=pissh
    GATEWAY=192.168.66.2

         ② 修改主机名和IP的映射关系(注意这里是加上 下面,而不是把上面的127.0.0.1给替换了)

    1 vim /etc/hosts

    3、root用户 重启网络,使配置生效

    /etc/init.d/network restart

    4.VMware克隆CentOS6.4后 eth0无法初始化/找不到eth0的问题

    修改/etc/udev/rules.d/70-persistent-net.rules //保存网卡MAC地址等信息的配置文件

    # PCI device 0x8086:0x100f (e1000)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="eth0-MAC", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

    # PCI device 0x8086:0x100f (e1000)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="eth1-MAC", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

    删除以上eth0的信息,将eth1的信息中的eth1-〉eth0

    # PCI device 0x8086:0x100f (e1000)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="eth1-MAC", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

    再将ifcfg-eth0中的MAC地址改成上面eth1-MAC地址,然后配置IP等信息,

    重启服务器,就可以了。




    欢迎对it热情的同学,加qq进行技术讨论; QQ:850922253
  • 相关阅读:
    [chrome]click事件会触发mouseleave
    鼠标的指针状态 以及 事件禁用
    CSS3 线性渐变(linear-gradient)
    css 的函数 calc() 、linear-gradient()、、、
    1.闰年的计算方法。 2.某一月的周数
    moment.js 使用方法总结
    Echarts 版本查看
    如何使用 onscroll / scrollTo() / scrollBy()
    水平居中、垂直居中
    【LeetCode】22. Generate Parentheses (I thought I know Python...)
  • 原文地址:https://www.cnblogs.com/zhangwensi/p/6407381.html
Copyright © 2020-2023  润新知