Message ID | 1512722126-20482-1-git-send-email-dev@kresin.me |
---|---|
State | Accepted |
Delegated to: | Mathias Kresin |
Headers | show |
Series | [LEDE-DEV] netifd: always send DHCPv4 hostname | expand |
On 08-12-17 09:35, Mathias Kresin wrote: > udhcpc doesn't send a hostname by default. Use the system hostname if > nothing else is specified, to always send a hostname. > > It syncs the behaviour to odhcpc, which always sends a hostname. > > Signed-off-by: Mathias Kresin <dev@kresin.me> > --- > package/network/config/netifd/files/lib/netifd/proto/dhcp.sh | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh > index ea02d68..143e445 100755 > --- a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh > +++ b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh > @@ -40,6 +40,7 @@ proto_dhcp_setup() { > append dhcpopts "-x $opt" > done > > + [ -z "$hostname" ] && hostname="$(cat /proc/sys/kernel/hostname)" > [ "$broadcast" = 1 ] && broadcast="-B" || broadcast= > [ "$release" = 1 ] && release="-R" || release= > [ -n "$clientid" ] && clientid="-x 0x3d:${clientid//:/}" || clientid="-C" Acked-by: Stijn Tintel <stijn@linux-ipv6.be>
On Fri, Dec 8, 2017 at 1:43 PM, Stijn Tintel <stijn@linux-ipv6.be> wrote: > On 08-12-17 09:35, Mathias Kresin wrote: >> udhcpc doesn't send a hostname by default. Use the system hostname if >> nothing else is specified, to always send a hostname. >> >> It syncs the behaviour to odhcpc, which always sends a hostname. >> >> Signed-off-by: Mathias Kresin <dev@kresin.me> >> --- >> package/network/config/netifd/files/lib/netifd/proto/dhcp.sh | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh >> index ea02d68..143e445 100755 >> --- a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh >> +++ b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh >> @@ -40,6 +40,7 @@ proto_dhcp_setup() { >> append dhcpopts "-x $opt" >> done >> >> + [ -z "$hostname" ] && hostname="$(cat /proc/sys/kernel/hostname)" >> [ "$broadcast" = 1 ] && broadcast="-B" || broadcast= >> [ "$release" = 1 ] && release="-R" || release= >> [ -n "$clientid" ] && clientid="-x 0x3d:${clientid//:/}" || clientid="-C" > Acked-by: Stijn Tintel <stijn@linux-ipv6.be> Acked-by: Hans Dedecker <dedeckeh@gmail.com> > > _______________________________________________ > Lede-dev mailing list > Lede-dev@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/lede-dev
Hi Mathias, On Fri, Dec 08, 2017 at 09:35:26AM +0100, Mathias Kresin wrote: > udhcpc doesn't send a hostname by default. Use the system hostname if > nothing else is specified, to always send a hostname. > > It syncs the behaviour to odhcpc, which always sends a hostname. Could we somehow allow to deliberately not send any hostname? ISC dhcpcd allows setting it to 'null' or 'localhost' for that purpose. There are two possible uses for not sending the hostname in the DHCP request: i) expecting the hostname to be assigned by the DHCP server ii) minimizing the amount of identifyable bits being sent, e.g. when connecting to public networks Cheers Daniel > > Signed-off-by: Mathias Kresin <dev@kresin.me> > --- > package/network/config/netifd/files/lib/netifd/proto/dhcp.sh | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh > index ea02d68..143e445 100755 > --- a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh > +++ b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh > @@ -40,6 +40,7 @@ proto_dhcp_setup() { > append dhcpopts "-x $opt" > done > > + [ -z "$hostname" ] && hostname="$(cat /proc/sys/kernel/hostname)" > [ "$broadcast" = 1 ] && broadcast="-B" || broadcast= > [ "$release" = 1 ] && release="-R" || release= > [ -n "$clientid" ] && clientid="-x 0x3d:${clientid//:/}" || clientid="-C" > -- > 2.7.4 > > > _______________________________________________ > Lede-dev mailing list > Lede-dev@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/lede-dev
Citeren Mathias Kresin <dev@kresin.me>: > udhcpc doesn't send a hostname by default. Use the system hostname if > nothing else is specified, to always send a hostname. Be aware that this might mean that some DHCP servers may assign a different IP in this case. If I switch to odhcpc, I *will* get a different IP address, despite the MAC address staying the same. > It syncs the behaviour to odhcpc, which always sends a hostname. As someone else already commented, I'd too would prefer if this changed functionality is optional and default to the existing behavior of not sending the hostname. > Signed-off-by: Mathias Kresin <dev@kresin.me> > --- > package/network/config/netifd/files/lib/netifd/proto/dhcp.sh | 1 + > 1 file changed, 1 insertion(+) > > diff --git > a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh > b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh > index ea02d68..143e445 100755 > --- a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh > +++ b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh > @@ -40,6 +40,7 @@ proto_dhcp_setup() { > append dhcpopts "-x $opt" > done > > + [ -z "$hostname" ] && hostname="$(cat /proc/sys/kernel/hostname)" > [ "$broadcast" = 1 ] && broadcast="-B" || broadcast= > [ "$release" = 1 ] && release="-R" || release= > [ -n "$clientid" ] && clientid="-x 0x3d:${clientid//:/}" || clientid="-C"
08.12.2017 21:14, Daniel Golle: > Hi Mathias, > > On Fri, Dec 08, 2017 at 09:35:26AM +0100, Mathias Kresin wrote: >> udhcpc doesn't send a hostname by default. Use the system hostname if >> nothing else is specified, to always send a hostname. >> >> It syncs the behaviour to odhcpc, which always sends a hostname. > > Could we somehow allow to deliberately not send any hostname? At least in context of this patch it's to late. I pushed the patch minutes prior your mail. > ISC dhcpcd allows setting it to 'null' or 'localhost' for that > purpose. > There are two possible uses for not sending the hostname in the DHCP > request: > i) expecting the hostname to be assigned by the DHCP server Shouldn't work it anyway by using the request hostname option? > ii) minimizing the amount of identifyable bits being sent, e.g. > when connecting to public networks Exactly that was the reason why I send the patch to the mailing list first. I wasn't sure if the absence of a default send hostname is considered as feature or a bug. After receiving the ACKs it was pretty much clear to me that it's considered as bug by others as well. Nevertheless I thought about this use case as well, but couldn't find a satisfying solution using the existing hostname uci option. I consider the strings 'null' and 'localhost' as valid hostnames. To my knowledge it isn't possible to pass NULL via uci and therefore it's impossible to distinguish whether the hostname was intentional set to nothing or it's expected that the systems hostname is send by default (as it's done by all dhcp clients I have seen so far). I was surprised to see that there was a mismatch in what is done for DHCPv4 (udhcpc) and DHCPv6 (odhcpc). I prefer to have the possible to create a DNS record - based on the send hostname - for dhcp clients by default and considered this issue as more pressing. But as usual, it depends on the use case. Mathias
diff --git a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh index ea02d68..143e445 100755 --- a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh +++ b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh @@ -40,6 +40,7 @@ proto_dhcp_setup() { append dhcpopts "-x $opt" done + [ -z "$hostname" ] && hostname="$(cat /proc/sys/kernel/hostname)" [ "$broadcast" = 1 ] && broadcast="-B" || broadcast= [ "$release" = 1 ] && release="-R" || release= [ -n "$clientid" ] && clientid="-x 0x3d:${clientid//:/}" || clientid="-C"
udhcpc doesn't send a hostname by default. Use the system hostname if nothing else is specified, to always send a hostname. It syncs the behaviour to odhcpc, which always sends a hostname. Signed-off-by: Mathias Kresin <dev@kresin.me> --- package/network/config/netifd/files/lib/netifd/proto/dhcp.sh | 1 + 1 file changed, 1 insertion(+)