zoukankan      html  css  js  c++  java
  • 001-网卡配置

      一般我们本机测试一些Linux服务集群时需要安装多台linux虚机,大多情况是安装一台模板机进行复制。

    在VirtualBox中进行复制后,我们需要注意网卡变更。

    修改内容包括mac地址,和IP相关配置。

      一,mac地址修改与VirtualBox提供的一致。

      centos中mac地址的修改在/etc/udev/rules.d/70-persistent-net.rules文件中。

    #
    # You can modify it, as long as you keep each rule on a single
    # line, and change only the value of the NAME= key.

    # PCI device 0x8086:0x100e (e1000)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:E5:A8:1A", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

    # PCI device 0x8086:0x100e (e1000)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:E5:A8:1A", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

    # PCI device 0x8086:0x100e (e1000) (custom name provided by external tool)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:e5:a8:1a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

    修改你使用的网卡为正确地址。

      二,修改网卡IP配置

      该文件在/etc/sysconfig/network-scripts/ifcfg-eth0 中,修改内容如下:

    DEVICE=eth1
    TYPE=Ethernet
    UUID=5f39aa83-e8ef-480f-ba36-00a7ebaa76d2
    ONBOOT=yes
    NM_CONTROLLED=yes
    BOOTPROTO=static或dhcp(动态分配就不需要手动设置网关,DNS这些信息)
    HWADDR=08:00:27:9A:E5:AC
    DEFROUTE=yes
    PEERDNS=yes
    PEERROUTES=yes
    IPV4_FAILURE_FATAL=yes
    IPADDR=192.168.31.120
    GATEWAY=192.168.31.1
    DNS1=192.168.1.1
    IPV6INIT=no
    USERCTL=no
    NAME="System eth1"

      当然修改完成后不会立即生效,你可以选择重启,或命令让其生效。

    重启网络
    # service network restart
    或者
    # /etc/init.d/network restart
     
    故障案例一:
    ifconfig...没有看到eth0.。然后重启网卡又报下面错误。
    故障现象:
    service network restart
    Shutting down loopback insterface:                                                                                                     [  OK  ]
    Bringing up loopback insterface:                                                                                                          [  OK  ]
    Bringing up interface eth0:  Device eth0 does not seem to be present,delaying initialization.                    [FAILED]
     
    首先,打开内容如下面例子所示:
    # vi /etc/udev/rules.d/70-persistent-net.rules
    # This file was automatically generated by the /lib/udev/write_net_rules
    # program, run by the persistent-net-generator.rules rules file.
    #
    # You can modify it, as long as you keep each rule on a single
    # line, and change only the value of the NAME= key.
    # PCI device 0x1022:0x2000 (pcnet32)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:8f:89:9
    7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
    # PCI device 0x1022:0x2000 (pcnet32)
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:50:bd:1
    7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
     
    记录下,eth1网卡的mac地址00:0c:29:50:bd:17
    接下来,打开/etc/sysconfig/network-scripts/ifcfg-eth0
    将 DEVICE="eth0"  改成  DEVICE="eth1"  ,
    将 HWADDR="00:0c:29:8f:89:97" 改成上面的mac地址  HWADDR="00:0c:29:50:bd:17"
    最后,重启网络
     
     
     
  • 相关阅读:
    浅析Python模块的引入和调用
    一篇文章带你了解CSS定位知识
    盘点4大下载神器,教你分分钟搞定文件下载
    Mysql查询语句进阶知识集锦
    (原创)高DPI适配经验系列:(四)高DPI适配示例
    (原创)高DPI适配经验系列:(三)字体与字号、缩放锚点
    (原创)IconFont(矢量图标字体)在Winform中的应用
    (原创)高DPI适配经验系列:(二)按DPI范围适配
    (原创)高DPI适配经验系列:(一)缩放比例与DPI对应关系
    [C#] (原创)一步一步教你自定义控件——06,MaskLayer(遮罩层)
  • 原文地址:https://www.cnblogs.com/ffeng/p/7397448.html
Copyright © 2011-2022 走看看