(Mark) (Ubuntu)Ubuntu 12.04 LTS 添加虛擬網卡設置硬件MAC地址 (Linux) (MAC)


一、添加虛擬網卡配置MAC

1. 安裝uml-utilities工具

sudo apt-get install uml-utilities

2.創建虛擬網卡 eth2

sudo tunctl -t eth2

3.為虛擬網卡eth2固定一個MAC地址

sudo ifconfig eth2 hw ether 00:11:22:33:44:55

4.啟用虛擬網卡eth2

sudo ifconfig eth2 up

5.查看虛擬網卡eht2的MAC

ifconfig eth2

eth2      Link encap:以太網  硬件地址 00:11:22:33:44:55 
          UP BROADCAST MULTICAST  MTU:1500  躍點數:1
          接收數據包:0 錯誤:0 丟棄:0 過載:0 幀數:0
          發送數據包:0 錯誤:0 丟棄:0 過載:0 載波:0
          碰撞:0 發送隊列長度:500 
          接收字節:0 (0.0 B)  發送字節:0 (0.0 B)

 注:在修改虛擬網卡eth2的MAC地址是要確保 eth2處於關閉狀態,如果未關閉使用

sudo ifconfig eth2 down

修改完成后再開啟

二、修改eth0 物理網卡的MAC

  1. Type the following command:
    sudo apt-get install uml-utilities
  2. Type the following command:

    cd /etc
  3. Open the rc.local file in your preferred text editor (vi, nano, etc.)

  4. Add the following lines to the end of the file. Replace XX:XX:XX:XX:XX:XX with the MAC address that you want to use:

    # Create the tap0 network interface:
    tunctl
    # Rename the tap0 interface to eth0:
    ip link set dev tap0 name eth0
    # Set the MAC address for the eth0 interface:
    ifconfig eth0 hw ether XX:XX:XX:XX:XX:XX
    # Bring up the eth0 interface:
    ifconfig eth0 up
  5. Save the changes to the rc.local file and exit the text editor.

  6. Restart the system.

  7. After the system has restarted, you can view the network interfaces by typing the following command:

    ifconfig


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM