openwrt wan lan口冲突自动切换ip地址

#!/bin/sh

WANADDR=`ubus call network.interface.wan status | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.'`
LANADDR=`ubus call network.interface.lan status | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.'`


echo "$WANADDR $LANADDR" >/dev/console
if [ "x$WANADDR" == "x$LANADDR" ]; then
	if [ "x$WANADDR" == "x192.168.10.1" ]; then
		uci set network.lan.ipaddr='193.168.20.1'
		uci commit
		/etc/init.d/network restart
	else
		uci set network.lan.ipaddr='193.168.10.1'
		uci commit
		/etc/init.d/network restart
	fi
fi

你可能感兴趣的:(Openwrt)