Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
Dnsmasq
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Dnsmasq
Commits
47b9ac59
Commit
47b9ac59
authored
Feb 23, 2015
by
Joachim Zobel
Committed by
Simon Kelley
Feb 23, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log parsing utils in contrib/reverse-dns
parent
0705a7e2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
0 deletions
+75
-0
contrib/reverse-dns/README
contrib/reverse-dns/README
+18
-0
contrib/reverse-dns/reverse_dns.sh
contrib/reverse-dns/reverse_dns.sh
+29
-0
contrib/reverse-dns/reverse_replace.sh
contrib/reverse-dns/reverse_replace.sh
+28
-0
No files found.
contrib/reverse-dns/README
0 → 100644
View file @
47b9ac59
Hi.
To translate my routers netstat-nat output into names that actually talk
to me I have started writing to simple shell scripts. They require
log-queries
log-facility=/var/log/dnsmasq.log
to be set. With
netstat-nat -n -4 | reverse_replace.sh
I get retranslated output.
Sincerely,
Joachim
contrib/reverse-dns/reverse_dns.sh
0 → 100644
View file @
47b9ac59
#!/bin/bash
# $Id: reverse_dns.sh 4 2015-02-17 20:14:59Z jo $
#
# Usage: reverse_dns.sh IP
# Uses the dnsmasq query log to lookup the name
# that was last queried to return the given IP.
#
IP
=
$1
qmIP
=
`
echo
$IP
|
sed
's#\.#\\.#g'
`
LOG
=
/var/log/dnsmasq.log
IP_regex
=
'^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'
if
!
[[
$IP
=
~
$IP_regex
]]
;
then
echo
-n
$IP
exit
fi
NAME
=
`
tac
$LOG
|
\
grep
" is
$IP
"
|
head
-1
|
\
sed
"s#.*
\(
[^ ]*
\)
is
$qmIP
.*#
\1
#"
`
if
[
-z
"
$NAME
"
]
;
then
echo
-n
$IP
else
echo
-n
$NAME
fi
contrib/reverse-dns/reverse_replace.sh
0 → 100644
View file @
47b9ac59
#!/bin/bash
# $Id: reverse_replace.sh 4 2015-02-17 20:14:59Z jo $
#
# Usage e.g.: netstat -n -4 | reverse_replace.sh
# Parses stdin for IP4 addresses and replaces them
# with names retrieved by reverse_dns.sh
#
DIR
=
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
&&
pwd
)
DNS
=
$DIR
/reverse_dns.sh
# sed regex
IP_regex
=
'[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'
while
read
LINE
;
do
if
grep
--quiet
$IP_regex
<<<
"
$LINE
"
;
then
IPs
=
`
sed
"s#.*
\b\(
$IP_regex
\)\b
.*#
\1
#g"
<<<
"
$LINE
"
`
IPs
=(
$IPs
)
for
IP
in
"
${
IPs
[@]
}
"
do
NAME
=
`
$DNS
$IP
`
# echo "$NAME is $IP";
LINE
=
"
${
LINE
/
$IP
/
$NAME
}
"
done
fi
echo
$LINE
done
< /dev/stdin
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