From b99328599570bbcfa41f3a94c2c8095be75d57d9 Mon Sep 17 00:00:00 2001 From: garywill Date: Thu, 24 Dec 2020 20:36:09 +0800 Subject: [PATCH] fix can't change mac addr --- README.md | 7 ++++--- lnxrouter | 14 +++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f4965b2..88ae622 100644 --- a/README.md +++ b/README.md @@ -291,8 +291,9 @@ Options: Notice 1: This script assume your host's default policy won't forward packets, so the script won't explictly ban forwarding in any - mode. In some case may cause unwanted communication between 2 - networks, which you should check if you want isolated network + mode. In some unexpected case may cause unwanted packets + leakage between 2 networks, which you should be aware of if you + want isolated network ``` > These changes to system will not be restored by script's cleanup: @@ -323,7 +324,7 @@ Wifi hotspot: [Buy me a coffee](https://github.com/garywill/receiving/blob/master/receiving_methods.md) , this project took me lots of time! -( ^_^)o自自o(^_^ ) +( ^\_^)o自自o(^_^ ) No? Okay, or just give me a star! diff --git a/lnxrouter b/lnxrouter index cd18c2f..da6d140 100644 --- a/lnxrouter +++ b/lnxrouter @@ -104,8 +104,9 @@ Options: Notice 1: This script assume your host's default policy won't forward packets, so the script won't explictly ban forwarding in any - mode. In some case may cause unwanted communication between 2 - networks, which you should check if you want isolated network + mode. In some unexpected case may cause unwanted packets + leakage between 2 networks, which you should be aware of if you + want isolated network Examples: $PROGNAME -i eth1 @@ -1388,7 +1389,7 @@ trap "die" SIGUSR2 mkdir -p $TMPDIR chmod 755 $TMPDIR 2>/dev/null -cd $TMPDIR +cd $TMPDIR || die "Couldn't change directory to linux-router's temporary path" CONFDIR=$(mktemp -d $TMPDIR/lnxrouter.${TARGET_IFACE}.conf.XXX) chmod 755 $CONFDIR @@ -1639,13 +1640,12 @@ fi #=========================== # initialize subnet interface -if [[ -n "$NEW_MACADDR" ]]; then - ip link set dev ${SUBNET_IFACE} address ${NEW_MACADDR} || die "Failed setting new MAC address" -fi - ip link set down dev ${SUBNET_IFACE} || die "Failed setting ${SUBNET_IFACE} down" ip addr flush ${SUBNET_IFACE} || die "Failed flush ${SUBNET_IFACE} IP" +if [[ -n "$NEW_MACADDR" ]]; then + ip link set dev ${SUBNET_IFACE} address ${NEW_MACADDR} || die "Failed setting new MAC address" +fi ip link set up dev ${SUBNET_IFACE} || die "Failed bringing ${SUBNET_IFACE} up"