Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
bde7fab3
Commit
bde7fab3
authored
Jan 22, 2016
by
gitmod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use netaddr to lookup mac address
parent
78148368
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
10 deletions
+5
-10
list_arp.py
src/opnsense/scripts/interfaces/list_arp.py
+5
-10
No files found.
src/opnsense/scripts/interfaces/list_arp.py
View file @
bde7fab3
...
@@ -34,17 +34,11 @@ import os
...
@@ -34,17 +34,11 @@ import os
import
os.path
import
os.path
import
sys
import
sys
import
ujson
import
ujson
from
netaddr
import
*
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
result
=
[]
result
=
[]
# import mac manufacturer mac address table (index by mac prefix)
mac_table
=
{}
if
os
.
path
.
isfile
(
'/usr/local/share/nmap/nmap-mac-prefixes'
):
for
mac
in
open
(
'/usr/local/share/nmap/nmap-mac-prefixes'
)
.
read
()
.
split
(
'
\n
'
):
if
len
(
mac
)
>
8
:
mac_table
[
mac
[
0
:
6
]]
=
mac
[
7
:]
# import dhcp_leases (index by ip address)
# import dhcp_leases (index by ip address)
dhcp_leases
=
{}
dhcp_leases
=
{}
dhcp_leases_filename
=
'/var/dhcpd/var/db/dhcpd.leases'
dhcp_leases_filename
=
'/var/dhcpd/var/db/dhcpd.leases'
...
@@ -70,9 +64,10 @@ if __name__ == '__main__':
...
@@ -70,9 +64,10 @@ if __name__ == '__main__':
'manufacturer'
:
''
,
'manufacturer'
:
''
,
'hostname'
:
''
'hostname'
:
''
}
}
manufacturer_mac
=
record
[
'mac'
]
.
replace
(
':'
,
''
)[:
6
]
.
upper
()
manufacturer_mac
=
EUI
(
record
[
'mac'
])
if
manufacturer_mac
in
mac_table
:
oui
=
manufacturer_mac
.
oui
record
[
'manufacturer'
]
=
mac_table
[
manufacturer_mac
]
if
oui
.
registration
()
.
org
:
record
[
'manufacturer'
]
=
oui
.
registration
()
.
org
if
record
[
'ip'
]
in
dhcp_leases
:
if
record
[
'ip'
]
in
dhcp_leases
:
record
[
'hostname'
]
=
dhcp_leases
[
record
[
'ip'
]][
'hostname'
]
record
[
'hostname'
]
=
dhcp_leases
[
record
[
'ip'
]][
'hostname'
]
result
.
append
(
record
)
result
.
append
(
record
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment