@@ -23,6 +23,7 @@ function load_config(name) {
2323 "uplink_mode" : type (ts .uplink_mode ) ? ts .uplink_mode : "" ,
2424 "uplink_ipv4" : type (ts .uplink_ipv4 ) ? ts .uplink_ipv4 : "" ,
2525 "uplink_gateway" : type (ts .uplink_gateway ) ? ts .uplink_gateway : "" ,
26+ "uplink_mac" : type (ts .uplink_mac ) ? ts .uplink_mac : "" ,
2627 "maintenance_interval" : int(ts .maintenance_interval ),
2728 "wireguard_servers" : {},
2829 "wireguard_interfaces" : {},
@@ -437,6 +438,7 @@ function uplink_maintenance(cfg) {
437438 let mode = cfg .uplink_mode ;
438439 let ipv4 = cfg .uplink_ipv4 ;
439440 let gw = cfg .uplink_gateway ;
441+ let mac = cfg .uplink_mac ;
440442
441443 if (interface_exists (netnsifname )) {
442444 // the uplink interface will sometimes leak out of the namespace on shutdown.
@@ -456,19 +458,7 @@ function uplink_maintenance(cfg) {
456458 shell_command ("ip -n " +netns +" link set " +netnsifname +" up" );
457459 } else if (mode == "bridge" ) {
458460 // or create a macvlan bridge:
459-
460- // Generate a deterministic mac first
461- let mac = split (trim (fs .readfile ("/sys/class/net/" +ifname +"/address" )), ":" );
462- let macpart = hex (mac [5 ]);
463- // Adds 42 to the hex-value, but subtracts 42 if we are to high to avoid counting over ff
464- if (macpart <= 167 ){
465- mac [5 ] = sprintf ("%x" , macpart + 42 );
466- } else {
467- mac [5 ] = sprintf ("%x" , macpart - 42 );
468- }
469- macstr = join (":" , mac );
470-
471- shell_command ("ip link add " +netnsifname +" address " +macstr +" link " +ifname +" type macvlan mode bridge" );
461+ shell_command ("ip link add " +netnsifname +" address " +mac +" link " +ifname +" type macvlan mode bridge" );
472462 shell_command ("ip link set dev " +netnsifname +" netns " +netns );
473463 shell_command ("ip -n " +netns +" link set up " +netnsifname +"" );
474464 } else {
0 commit comments