<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On 11 Jul 2013, at 06:26, Ville Mattila <<a href="mailto:ville@mattila.fi">ville@mattila.fi</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div>Hi,<br><br></div><div>I have been working with tinc network where one host will provide the IP addresses over DHCP to each connected node. Tinc runs in switch mode.<br><br>It seems that the HWaddr of the tinc interface is regenerated every time when tinc is (re)started. As a result, DHCP server will assign a new IP for the host. Is there any configuration variable we could use to avoid HWaddr changing?<br>
<br></div><div>Currently, I have added a short snippet into tinc-up script that persists the (once given) HWaddr to a file and tries to reset it before starting dhclient. This works, but I feel it a bit hacky solution...<br>
<br></div><div>-- tinc-up --<br></div><div><br>#!/bin/sh<br>set -e<br><br>MACFILE="/etc/tinc/mynet/mac"<br>if [ -e $MACFILE ]; then<br> MAC=`cat $MACFILE`<br> ifconfig $INTERFACE hw ether $MAC<br>fi<br><br>dhclient $INTERFACE &<br>
MAC=`ip link show mynet | awk '/ether/ {print $2}'`<br>echo $MAC > $MACFILE<br></div></div></blockquote><br></div><div>In my configuration we do:</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>AWMAC1="$(printf '42:00:00:00:01:%02x' $AWSUBNET)"</div><div><div><span class="Apple-tab-span" style="white-space:pre"> </span>AWMAC2="$(printf '42:00:00:00:02:%02x' $AWSUBNET)"</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>AWMAC3="$(printf '42:00:00:00:03:%02x' $AWSUBNET)"</div><div><br></div></div><div>AWSUBNET is a number in the range of 190 - 199 in our case. Notice how 42 sets b2 in top byte, the 'locally administered' bit (see <a href="http://en.wikipedia.org/wiki/MAC_address">http://en.wikipedia.org/wiki/MAC_address</a>). Isn't it the answer to everything?</div><div><br></div><div>tinc-up looks like:</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>/sbin/ifconfig $INTERFACE ether '@@AWMAC2@@'</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>/sbin/ifconfig $INTERFACE up</div><div><br></div><div>Background: The culprit is not so much tinc as is the underlying OS that has to generate a globally unique MAC address. for generated interfaces The same problem occurs on bridges on FreeBSD (very annoying when trying to use static IP through DHCP there). I guess that we applied this approach for the same reason that you do, but not sure.</div><div><br></div><div>Nick</div><div><br></div><div><br></div></body></html>