當前位置:首頁 » 幣種行情 » eth0的MAC地址

eth0的MAC地址

發布時間: 2025-02-13 04:08:48

『壹』 在linux裡面怎麼獲取mac地址

可以使用ifconfig命令。ifconfig是linux中用於顯示或配置網路設備(網路介面卡)的命令,英文全稱是network interfaces configuring。它能夠顯示網卡的IP地址、子網掩碼、廣播地址、硬體地址等信息。

用法示例:

查看網卡eth0的mac地址

$ ifconfig eth0

mac地址位於上圖中的紅色方框處。

『貳』 android如何獲取乙太網mac地址

本文講述無線網和乙太網mac地址獲取的方法: 1.乙太網獲取mac地址 因為機頂盒系統是linux內核的,假設ethernet是eth0,那麼可以從以下文件中讀取相關信息:/sys/class/net/eth0/address方法1: public static String loadFileAsString(String filePath) throws java.io.IOException{ StringBuffer fileData = new StringBuffer(1000); BufferedReader reader = new BufferedReader(new FileReader(filePath)); char[] buf = new char[1024]; int numRead=0; while((numRead=reader.read(buf)) != -1){ String readData = String.valueOf(buf, 0, numRead); fileData.append(readData); } reader.close(); return fileData.toString();}/** Get the STB MacAddress*/public String getMacAddress(){ try { return loadFileAsString("/sys/class/net/eth0/address") .toUpperCase().substring(0, 17); } catch (IOException e) { e.printStackTrace(); return null; }}方法2:NetworkInterface NIC = NetworkInterface.getByName("eth0"); byte[] buf = NIC.getHardwareAddress(); for (int i = 0; i < buf.length; i++) { mac = mac + byteHEX(buf);}if (mac != null && !"".equals(mac)) { }2.wifi獲取mac和ip首先要在manifest.xml文件中添加許可權: <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>獲取mac的代碼如下WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); WifiInfo info = wifi.getConnectionInfo(); return info.getMacAddress();獲取Ip的代碼public String getLocalIpAddress() { try { for (Enumeration<NetworkInterface> en = NetworkInterface .getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface intf = en.nextElement(); if (intf.getName().toLowerCase().equals("eth0")) { for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { InetAddress inetAddress = enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress()) { String ipaddress = inetAddress.getHostAddress().toString(); if(!ipaddress.contains("::")){//ipV6的地址 return ipaddress; } } } } else { continue; } } } catch (Exception ex) { Log.e("WifiPreference IpAddress", ex.toString()); } return null; }

『叄』 openWRT如何修改MAC地址

1、修改 eth0 mac地址:
編輯 /etc/rc.local,ifconfig eth0 down;ifconfig eth0 hw ether d8:64:c7:5e:f1:c6;ifconfig eth0 up。
2、修改wireless mac地址。
這就最糾結了直接修改 /etc/config/wireless中的mac是沒用的,並且修改後無線網路會無法啟動。
在研究了/sbin/wifi腳本後,只能通過迂迴戰術來進行解決。
編輯 /sbin/wifi;修改如下一段,增加內容。
set_wifi_up() {
echo wifi_up;ls /tmp/run/*.conf

kill `cat /var/run/wifi-phy0.pid`
sed -i s/^bssid=.*/bssid=d8:64:c7:5f:f1:c6/ /var/run/hostapd-phy0.conf
hostapd -P /var/run/wifi-phy0.pid -B /var/run/hostapd-phy0.conf

local cfg="$1"
echo wifi_up 2;ls /tmp/run/*.conf
local ifname="$2"
echo wifi_up 3;ls /tmp/run/*.conf
uci_set_state wireless "$cfg" up 1
uci_set_state wireless "$cfg" ifname "$ifname"

}

3、修改完成 。
sync;reboot 重啟,就能看到所有修改都生效了。

熱點內容
以太坊最開始多少錢 發布:2025-02-13 09:34:12 瀏覽:956
區塊鏈近期項目 發布:2025-02-13 09:33:18 瀏覽:930
nba球員要比特幣工資 發布:2025-02-13 09:14:36 瀏覽:96
區塊鏈理論韋一風 發布:2025-02-13 09:01:01 瀏覽:150
btc余額寶是什麼 發布:2025-02-13 08:38:00 瀏覽:568
區塊鏈行為金融學 發布:2025-02-13 08:25:44 瀏覽:935
xdaggpu挖礦 發布:2025-02-13 08:20:32 瀏覽:15
區塊鏈活躍地址 發布:2025-02-13 08:19:50 瀏覽:209
wings區塊鏈 發布:2025-02-13 08:19:43 瀏覽:928
蜜蜂鏈區塊鏈 發布:2025-02-13 08:11:45 瀏覽:288