Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autodetection of MAC address, NTP improvements, oui.txt cleanup #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tlhackque
Copy link

@tlhackque tlhackque commented Feb 15, 2020

This fixes several bugs - the most serious of which is failure to include
the NTP timestamp in the result. Crashes due to invalid input are also
fixed. Usage is simplified so that it most cases, no user input is required.
However, no functionality is lost: prompts and overrides are still available.

Changes include:

  1. use ip link or ifconfig to select a MAC address if not user-specified
  2. handle upper-case hex input
  3. allow user to specify an NTP server
  4. if ntpq fails, try fallback to ntpdate. (Current ntp servers often
    block 'rv'.commands.)
  5. ntp utilities will try all IP addresses assigned to a host.
    Deal with multiple responses.
  6. If oui.txt is downloaded, place it in /tmp and remove it on exit.
  7. Fix use of undefined 'date' (instead of 'clock') in GID, use LSB of SHA per RFC
  8. Use variables for defaults to simplify customization
  9. Default to not prompting; use -i for prompts.
  10. Add usage and command line options.
  11. Ensure all errors reported to stderr. Fully validate input.
  12. Suppress leading zeros in ULA
  13. Don't depend on GNU sed's extended REs or GNU echo -ne
  14. By default, only output generated ULA. -v for verbose mode.
  15. Add option to get (download) a copy of oui.txt
    Note that ntpq/ntpdate can take a while to get a timestamp.
    ntpq may timeout, but the script will try to recover using ntpdate.

Manually providing a MAC address and/or timestamp should not be
necessary. Doing so without understanding the RFC is likely to
reduce the uniqueness of the generated address. -i is provided
for advanced users.

The MAC autoselection uses the first interface with an ethernet
address. The address of another interface can be used safely.
However, since the purpose is only to seed a hash to identify
the network, there is no reason to prefer one over another.

The timestamp ensures that a given interface can generate more than
one ULA. The only reason to set it manually is deterministic
debugging.

Closes #2 - Part 1 (MAC case). Part two is not an issue: a broadcast addresses can never be a physical MAC address.

1) use ip link or ifconfig to select a MAC address if not user-specified
2) handle upper-case hex input
3) allow user to specify an NTP server
4) if ntpq fails, try fallback to ntpdate. (Current ntp servers often
   block 'rv'.commands.)
5) ntp utilities will try all IP addresses assigned to a host.
   Deal with multiple responses.
6) If oui.txt is downloaded, place it in /tmp and remove it on exit.
7) Fix use of undefined 'date' (instead of 'clock') in GID, use LSB of SHA per RFC
8) Use variables for defaults to simplify customization
9) Default to not prompting; use -i for prompts.
10) Add usage and command line options.
11) Ensure all errors reported to stderr.  Fully validate input.
12) Suppress leading zeros in ULA
13) Don't depend on GNU sed's extended REs or GNU echo -ne
14) By default, only output generated ULA.  -v for verbose mode.
15) Add option to get (download) a copy of oui.txt
Note that ntpq/ntpdate can take a while to get a timestamp.
ntpq may timeout, but the script will try to recover using ntpdate.

Manually providing a MAC address and/or timestamp should not be
necessary.  Doing so without understanding the RFC is likely to
reduce the uniqueness of the generated address.  -i is provided
for advanced users.

The MAC autoselection uses the first interface with an ethernet
address. The address of another interface can be used safely.
However, since the purpose is only to seed a hash to identify
the network, there is no reason to prefer one over another.

The timestamp ensures that a given interface can generate more than
one ULA.  The only reason to set it manually is deterministic
debugging
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle uppercase MAC address
1 participant