瀏覽代碼

add option for setting the mac address (#1014)

SVN-Revision: 5690
Felix Fietkau 19 年之前
父節點
當前提交
7cc6503877
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      package/base-files/files/lib/network/config.sh

+ 5 - 2
package/base-files/files/lib/network/config.sh

@@ -66,6 +66,7 @@ setup_interface() {
 	local iface="$1"
 	local config="$2"
 	local proto
+	local macaddr
 
 	[ -n "$config" ] || {
 		config=$(find_config "$iface")
@@ -76,7 +77,8 @@ setup_interface() {
 	config_get iftype "$config" type
 	
 	ifconfig "$iface" 2>/dev/null >/dev/null && {
-		# make sure the interface is removed from any existing bridge
+		# make sure the interface is removed from any existing bridge and brought down
+		ifconfig "$iface" down
 		unbridge "$iface"
 	}
 
@@ -101,7 +103,8 @@ setup_interface() {
 	
 	# Interface settings
 	config_get mtu "$config" mtu
-	$DEBUG ifconfig "$iface" ${mtu:+mtu $mtu} up
+	config_get macddr "$config" macaddr
+	$DEBUG ifconfig "$iface" ${macaddr:+hw ether "$macaddr"} ${mtu:+mtu $mtu} up
 
 	pidfile="/var/run/$iface.pid"
 	case "$proto" in