我目前使用 net.ipv6.conf.all.use_tempaddr=2 来获取 IPv6 隐私地址(具有随机主机部分,每天重新生成几次)。我需要动态 DNS,因为计算机连接到不同的网络,这会改变地址的网络部分。我正在使用 curl 下载动态 DNS url,并希望它使用使用我的 MAC 的非随机地址。我怎样才能让 curl 优先使用非隐私地址?
答案1
您可以使用 curl 选项强制 curl 使用特定的源地址--interface
,例如
curl --interface 2001:db8::f00:1234 http://example.com/updatedns.html
答案2
我用了阿吉米奇的回答以及一些脚本来执行此操作。(如果有人有更好的获取地址的方法,我会很高兴听到。)您需要安装卷曲
#! /bin/sh
# (C) 2011 Erik B. Andersen <[email protected]>
# Licensed under the latest version of the GPL as published by the Free Software Foundation
# Don't bother to reload when lo is configured.
if [ "$IFACE" = lo ]; then
echo "Interface lo; skipping"
exit 0
fi
if [ ! -e /usr/bin/curl ]; then
echo "Curl not installed; skipping"
exit 0
fi
if [ ! -e /sbin/ifconfig ]; then
echo "Ifconfig not installed; skipping"
exit 0
fi
if [ ! -e /bin/grep ]; then
echo "Grep not installed; skipping"
exit 0
fi
if [ ! -e /usr/bin/tr ]; then
echo "Tr not installed; skipping"
exit 0
fi
if [ ! -e /usr/bin/tail ]; then
echo "Tail not installed; skipping"
exit 0
fi
Hostname="something.example.org"
Password="something"
Interface="wlan0"
echo "Running curl"
curl --interface $(/sbin/ifconfig ${Interface} | /bin/grep "Global" | /usr/bin/tr "/" "\n" | /usr/bin/tr " " "\n" | /bin/grep "ff:fe"| /usr/bin/tail -n 1) -6 http://${Hostname}:${Password}@dyn.dns.he.net/nic/update?hostname=${Hostname}
exit 0