it would be a very nice feature (and could actually simplify things) if the net.ethx scripts automatically added/removed entries from /etc/hosts on start and stop. this is especially useful for those with laptops or generally DHCP driven addresses that are subject to change. it is a trivial change too!. examples (this works very well for me so far): to add a line in the start: echo "${ip} `hostname` # added by DHCP" >> /etc/hosts then to remove it in stop: sed -i "/^${ip} `hostname` # added by DHCP$/ d" /etc/hosts i have an example version which seems to work flawlessly (though i'm sure you guys could give it even further enhancment).
Created attachment 30763 [details] example implementation (lines 106/217/218 are relavent changes)
Created attachment 30764 [details] improvment, implements it as postup/predown functions (all changes at bottom now)
This isn't how DHCP should work. If you do this then you're fooling yourself (well, okay, your machine ;-) into thinking that the hostname is associated with the address. If you want to do that, it's fine, but it's not for everybody. Instead, you should be using "dhcpcd -h hostname eth0" (where "hostname" is the preferred name of your machine) to request a certain name from the DHCP server. If things are configured correctly, this will also result in an updated DNS entry for your hostname/address association. In that case there is no need to update /etc/hosts at all. To accomplish this you can set dhcpcd_eth0="-h hostname" in /etc/conf.d/net Another alternative is to put your hostname on the same line with localhost so that you can always ping yourself, etc. Anyway, your solution isn't a good one for most people. Thanks for the suggestion, though. Glad to hear you can make use of the preup and predown functions.