OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • English Forums »
  • Development and Code Review (Moderator: fabian) »
  • How to update MAC vendor db?
« previous next »
  • Print
Pages: [1] 2

Author Topic: How to update MAC vendor db?  (Read 9895 times)

Werner Fischer

  • Jr. Member
  • **
  • Posts: 66
  • Karma: 14
  • Working at Thomas-Krenn, doing lot of Open Source
    • View Profile
    • Thomas-Krenn-Wiki
How to update MAC vendor db?
« on: November 23, 2018, 03:50:45 pm »
The status site "status_interfaces.php" shows the vendor of a MAC address.

We have now acquired the MAC vendor range DC58BC, which is now listed at IEEE, see
https://regauth.standards.ieee.org/standards-ra-web/pub/view.html#registries and http://standards-oui.ieee.org/oui/oui.txt

My question is: where does OPNsense store this oui.txt? (I'd like to contribute a patch, so that future OPNsense version show the vendor "Thomas-Krenn.AG" for MAC addresses starting with DC:58:BC  ;)

Thx and best regards,
Werner
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 17701
  • Karma: 1615
    • View Profile
Re: How to update MAC vendor db?
« Reply #1 on: November 26, 2018, 09:41:21 am »
Hi Werner,

The database is pulled in via https://pypi.org/project/netaddr/

The library itself wasn't renewed since January 2017 though...


Cheers,
Franco
Logged

xpac

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: How to update MAC vendor db?
« Reply #2 on: January 13, 2020, 03:56:52 pm »
This is the most easy to find posting on this issue via Google.
As this is still an issue and the file is still as old as before, I've opened an issue on this:
https://github.com/opnsense/core/issues/3883
Logged

XeroX

  • Full Member
  • ***
  • Posts: 114
  • Karma: 7
    • View Profile
Re: How to update MAC vendor db?
« Reply #3 on: September 17, 2020, 11:25:28 pm »
Finally the Package including Databases have been updated (last more than 3 years ago)

Can we get an update of this package to have finally granular vendor mac addr lookup?

https://netaddr.readthedocs.io/en/latest/changes.html
Release: 0.7.20
Date: 19 Jun 2020

(This is at least the used library for ARP Table?!)
https://github.com/opnsense/core/blob/master/src/opnsense/scripts/interfaces/list_macdb.py
« Last Edit: September 17, 2020, 11:27:24 pm by XeroX »
Logged

XeroX

  • Full Member
  • ***
  • Posts: 114
  • Karma: 7
    • View Profile
Re: How to update MAC vendor db?
« Reply #4 on: September 18, 2020, 12:31:12 am »
Works like a charm on ARP Table. However breaks Vendor Lookup in DHCP completely.

distinfo
Code: [Select]
TIMESTAMP = 1600381665
SHA256 (netaddr-0.7.20.tar.gz) = d09252e5aec3913815d77eb8e8ea8fa6eb33521253e52f977f6abaa964776f3e
SIZE (netaddr-0.7.20.tar.gz) = 1889698

Code: [Select]
rm files/patch-setup.py
Makefile
Code: [Select]
--- Makefile.old        2020-09-18 00:29:47.359512000 +0200
+++ Makefile    2020-09-18 00:29:53.599067000 +0200
@@ -2,7 +2,7 @@
 # $FreeBSD$

 PORTNAME=      netaddr
-PORTVERSION=   0.7.19
+PORTVERSION=   0.7.20
 PORTREVISION=  1
 CATEGORIES=    net python
 MASTER_SITES=  CHEESESHOP

EDIT:
DHCP Leases uses the following command:
configctl interface list macdb json
Execute error

Its broken as a method does not exist anymore:

Traceback (most recent call last):
  File "/usr/local/opnsense/scripts/interfaces/list_macdb.py", line 39, in <module>
    if os.path.isfile(netaddr.eui.ieee.OUI_REGISTRY_PATH):
AttributeError: module 'netaddr.eui.ieee' has no attribute 'OUI_REGISTRY_PATH'

https://github.com/netaddr/netaddr/commit/5b2807ff91640c959dc358334f626cea0e28778c

EDIT2:
0.8.0 released 6 days ago.
« Last Edit: September 18, 2020, 01:33:52 am by XeroX »
Logged

XeroX

  • Full Member
  • ***
  • Posts: 114
  • Karma: 7
    • View Profile
Re: How to update MAC vendor db?
« Reply #5 on: September 18, 2020, 01:31:18 am »
Bad code and ARP Vendor Lookup works different than DHCP Leases. DHCP leases always parses the complete list, instead of looking up each single item with netaddr method. I'm not a programmer, I may check how to build this better.

Fix for DHCP:
/usr/local/opnsense/scripts/interfaces/list_macdb.py
Code: [Select]
--- list_macdb.py.old   2020-09-18 01:28:10.300640000 +0200
+++ list_macdb.py       2020-09-18 01:27:01.729241000 +0200
@@ -27,12 +27,11 @@
 import os.path
 import sys
 import ujson
-import netaddr.eui.ieee

 if __name__ == '__main__':
     result=dict()
-    if os.path.isfile(netaddr.eui.ieee.OUI_REGISTRY_PATH):
-        for line in open(netaddr.eui.ieee.OUI_REGISTRY_PATH, 'rb'):
+    if os.path.isfile('/usr/local/lib/python3.7/site-packages/netaddr/eui/oui.txt'):
+        for line in open('/usr/local/lib/python3.7/site-packages/netaddr/eui/oui.txt', 'rb'):
             line = line.decode()
             if line.find('(base 16)') > -1:
                 parts=line.split('(base 16)')
« Last Edit: September 18, 2020, 09:34:51 am by XeroX »
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 17701
  • Karma: 1615
    • View Profile
Re: How to update MAC vendor db?
« Reply #6 on: September 18, 2020, 08:36:40 am »
Is that not exactly the same? Besides, hardcoding 3.7 will break on the next Python update.


Cheers,
Franco
Logged

XeroX

  • Full Member
  • ***
  • Posts: 114
  • Karma: 7
    • View Profile
Re: How to update MAC vendor db?
« Reply #7 on: September 18, 2020, 09:34:10 am »
Morning franco,
what do you mean exactly the same? referred to?

I know it breaks, will try to improve that, I'm quiet new to python.
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 17701
  • Karma: 1615
    • View Profile
Re: How to update MAC vendor db?
« Reply #8 on: September 18, 2020, 09:37:55 am »
Hi there :)

This looks for a file:

if os.path.isfile(netaddr.eui.ieee.OUI_REGISTRY_PATH):

This looks for a file:

if os.path.isfile('/usr/local/lib/python3.7/site-packages/netaddr/eui/oui.txt'):

It is probable that netaddr.eui.ieee.OUI_REGISTRY_PATH actually is /usr/local/lib/python3.7/site-packages/netaddr/eui/oui.txt ;)


Cheers,
Franco
Logged

XeroX

  • Full Member
  • ***
  • Posts: 114
  • Karma: 7
    • View Profile
Re: How to update MAC vendor db?
« Reply #9 on: September 18, 2020, 10:23:08 am »
Oh yes, franco. You‘re correct.

Check the commit I posted on netaddr. The method has been removed. That‘s why changed it.

https://github.com/netaddr/netaddr/commit/5b2807ff91640c959dc358334f626cea0e28778c

EDIT:
Here we go:

Code: [Select]
--- list_macdb.py.old   2020-09-18 10:42:50.178232000 +0200
+++ list_macdb.py       2020-09-18 10:39:20.059022000 +0200
@@ -27,12 +27,12 @@
 import os.path
 import sys
 import ujson
-import netaddr.eui.ieee
+import imp

 if __name__ == '__main__':
     result=dict()
-    if os.path.isfile(netaddr.eui.ieee.OUI_REGISTRY_PATH):
-        for line in open(netaddr.eui.ieee.OUI_REGISTRY_PATH, 'rb'):
+    if os.path.isfile((imp.find_module('netaddr')[1])+'/eui/oui.txt'):
+        for line in open((imp.find_module('netaddr')[1])+'/eui/oui.txt', 'rb'):
             line = line.decode()
             if line.find('(base 16)') > -1:
                 parts=line.split('(base 16)')
« Last Edit: September 18, 2020, 10:43:49 am by XeroX »
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 17701
  • Karma: 1615
    • View Profile
Re: How to update MAC vendor db?
« Reply #10 on: September 22, 2020, 10:58:56 am »
Thanks, this was added to the development branch. We will work on a netaddr update right after 20.7.3 is out.


Cheers,
Franco
Logged

XeroX

  • Full Member
  • ***
  • Posts: 114
  • Karma: 7
    • View Profile
Re: How to update MAC vendor db?
« Reply #11 on: September 22, 2020, 06:19:35 pm »
Great franco, thank you!

Hope you can implement 0.8.0 directly and skip 0.7.20.

If you need any help or pull request let me know.

Which branch is it?
« Last Edit: September 22, 2020, 06:21:10 pm by XeroX »
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 17701
  • Karma: 1615
    • View Profile
Re: How to update MAC vendor db?
« Reply #12 on: September 23, 2020, 01:40:35 pm »
More discussion here. I'm not sure where this stands in FreeBSD as there is some kerfuffle about Python version support.

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=249382


Cheers,
Franco
Logged

XeroX

  • Full Member
  • ***
  • Posts: 114
  • Karma: 7
    • View Profile
Re: How to update MAC vendor db?
« Reply #13 on: December 09, 2020, 12:23:17 pm »
Any updates on this?
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 17701
  • Karma: 1615
    • View Profile
Re: How to update MAC vendor db?
« Reply #14 on: December 11, 2020, 08:50:40 pm »
I asked on the FreeBSD bug tracker. Another ticket here https://github.com/opnsense/ports/issues/110
Logged

  • Print
Pages: [1] 2
« previous next »
  • OPNsense Forum »
  • English Forums »
  • Development and Code Review (Moderator: fabian) »
  • How to update MAC vendor db?
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2