【hadoop】 1007-如何建立网卡和MAC地址的关联

来源:互联网 发布:经典java编程面试题 编辑:程序博客网 时间:2024/05/14 21:38
1、如何修改eth3 为eth0,并且eth0 和 192.168.2.31绑定
[hadoop@cloud01 .ssh]$ ifconfig
eth3      Link encap:Ethernet  HWaddr 00:0C:29:D5:4D:6E 
          inet addr:192.168.2.31  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fed5:4d6e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9168 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9717 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:879381 (858.7 KiB)  TX bytes:2297665 (2.1 MiB)
          Interrupt:19 Base address:0x2024

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:47128 errors:0 dropped:0 overruns:0 frame:0
          TX packets:47128 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:7594343 (7.2 MiB)  TX bytes:7594343 (7.2 MiB)
2、找到网卡和MAC映射文件
[hadoop@cloud01 ~]$ sudo find /etc/ -name "*net.rules"
[sudo] password for hadoop:
/etc/udev/rules.d/70-persistent-net.rules



3、修改网卡和MAC映射文件
修改前:
[hadoop@cloud01 ~]$ 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:3c:bf:e7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x1022:0x2000 (vmxnet)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:df:da:d1", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x1022:0x2000 (vmxnet)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:de:84:a7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

# PCI device 0x1022:0x2000 (vmxnet)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:d5:4d:6e", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"

修改后:
[hadoop@cloud01 ~]$ sudo vi /etc/udev/rules.d/70-persistent-net.rules
[hadoop@cloud01 ~]$ more /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:d5:4d:6e", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

4、sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
TYPE=Ethernet
BOOTPROTO="static"
IPADDR=192.168.2.31
PREFIX=24
GATEWAY=192.168.2.1
NETMASK="255.255.255.0"
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=nod
UUID=5f068003-422b-4dfc-a417-15535b85c4aa
ONBOOT=yes
LAST_CONNECT=1418095247

5、reboot

6、重新查看
hadoop@cloud01 ~]$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:D5:4D:6E 
          inet addr:192.168.2.31  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fed5:4d6e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:43 errors:0 dropped:0 overruns:0 frame:0
          TX packets:46 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4950 (4.8 KiB)  TX bytes:6512 (6.3 KiB)
          Interrupt:19 Base address:0x2024

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

0 0
原创粉丝点击