Generating a random hostname

Roland Smith rsmith at xs4all.nl
Wed Mar 17 22:50:06 UTC 2010


On Wed, Mar 17, 2010 at 05:06:30PM -0500, Peter Steele wrote:
> Is there any facility in FreeBSD for generating a random hostname? We have a
> template with a fixed hostname that has to be changed after the template is
> closed. It would be useful to have a hostname generated randomly.

For random strings, I tend to use openssl (e.g. with base64 encoding);

    openssl rand -base64 18

You do run the risk here of getting non-alphabetic characters here, so you
might want to filter those:

    openssl rand -base64 18| sed 's|[^[:alpha:]]||g'

Or if you are fine with just hex numbers;

    openssl rand 18 | hexdump -e '8 "%X" "\n"'

Roland
-- 
R.F.Smith                                   http://www.xs4all.nl/~rsmith/
[plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated]
pgp: 1A2B 477F 9970 BA3C 2914  B7CE 1277 EFB0 C321 A725 (KeyID: C321A725)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20100317/8374bc7f/attachment.pgp


More information about the freebsd-questions mailing list