+#################### compute INTERFACE_LAN
+# use /proc/net/dev instead of a hard-wired list
+function gather_interfaces () {
+ python <<EOF
+for line in file("/proc/net/dev"):
+ if ':' not in line: continue
+ ifname=line.replace(" ","").split(":")[0]
+ if ifname.find("lo")==0: continue
+ if ifname.find("br")==0: continue
+ if ifname.find("virbr")==0: continue
+ if ifname.find("tap")==0: continue
+ print ifname
+EOF
+}
+
+function discover_interface () {
+ for ifname in $(gather_interfaces); do
+ ip link show $ifname | grep -qi 'state UP' && { echo $ifname; return; }
+ done
+ # still not found ? that's bad
+ echo unknown
+}
+INTERFACE_LAN=$(discover_interface)
+echo Using physical interface $INTERFACE_LAN
+
+####################