Welcome to Yumao′s Blog.
OpenWRT多網關情況下MiniUpnpd添加映射失敗501
, 2020年07月05日 , Linux , 评论 在〈OpenWRT多網關情況下MiniUpnpd添加映射失敗501〉中留言功能已關閉 ,

更新了OpenWTR1907之後發生的靈異事件
upnpd無法自動添加映射
查詢詳細日志後發現返回內容

Sun Jul  5 08:41:59 2020 daemon.info miniupnpd[7417]: HTTP REQUEST from [::ffff:172.20.20.249]:36975 : POST /ctl/CmnIfCfg (HTTP/1.1)
Sun Jul  5 08:41:59 2020 daemon.debug miniupnpd[7417]: Host: 172.20.20.254:5000
Sun Jul  5 08:41:59 2020 daemon.info miniupnpd[7417]: SOAPAction: urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1#GetCommonLinkProperties
Sun Jul  5 08:41:59 2020 daemon.info miniupnpd[7417]: HTTP REQUEST from [::ffff:172.20.20.249]:36976 : POST /ctl/IPConn (HTTP/1.1)
Sun Jul  5 08:41:59 2020 daemon.debug miniupnpd[7417]: Host: 172.20.20.254:5000
Sun Jul  5 08:41:59 2020 daemon.info miniupnpd[7417]: SOAPAction: urn:schemas-upnp-org:service:WANIPConnection:2#GetExternalIPAddress
Sun Jul  5 08:41:59 2020 daemon.err miniupnpd[7417]: Failed to get ip address for interface
Sun Jul  5 08:41:59 2020 daemon.info miniupnpd[7417]: Returning UPnPError 501: Action Failed


翻找OpenWRT論壇發現有人有同樣情況發生
大概會發生在多網關多越點的情況下
MiniUpnpd會啓動的時候掃描所有的網關
然後如果不指定網關的網卡或者網關地址的話
掃描錯誤的網關就會導致映射添加失敗

那麽就查詢下/etc/init.d/miniupnpd看看是怎麽掃描的

        echo "ext_ifname=$ifname"
        echo "ext_ifname6=$ifname6"
        [ -n "$external_ip" ] && echo "ext_ip=$external_ip"
        //...
        if [ -n "$external_iface" ] ; then
                network_get_device ifname "$external_iface"
        else
                if [ -n "$external_zone" ] ; then
                        ifname=$(fw3 -q zone "$external_zone" 2>/dev/null | head -1)
                else
                        network_find_wan external_iface && \
                                network_get_device ifname "$external_iface"
                fi
        fi

那就簡單了
直接設置外網網卡或者IP即可

// 綁定外網網卡
uci set upnp.config.external_iface='wan'
uci set upnp.config.external_iface6='wan'
// 或者綁定外網IP
uci set upnp.config.external_ip='115.219.145.0'
uci commit
/etc/init.d/miniupnpd restart
关键字:, , ,

评论已关闭