-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
piholeDebug - Get default route robustly #6303
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR.
Regex always give me a headache - whats about a more human-friendly approach using jp -j
?
nanopi@nanopi:~$ ip -4 -j route show default
[{"dst":"default","gateway":"10.0.1.1","dev":"end0","protocol":"static","metric":100,"flags":[]}]
nanopi@nanopi:~$ ip -j -4 route show default | jq -r '.[0].dev'
end0
nanopi@nanopi:~$ ip -j -4 route show default | jq -r '.[0].gateway'
10.0.1.1
It's slower than the sed
but I think this does not matter in the debug script
I must say I like the explicit "null" from jq if there is nothing there. I'll update with jq instead of sed. |
4b22b1d
to
eeca1cd
Compare
The The Alternatively, we could install |
Determine address and interface of default route by preceeding 'via' and 'dev' fields in json output instead of plain text field position. Log if unable to determine default gateway Signed-off-by: Rob Gill <rrobgill@protonmail.com>
The |
|
Great! |
This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there: https://discourse.pi-hole.net/t/pi-hole-core-v6-1-3-released/81168/1 |
What does this PR aim to accomplish?:
Get information about the default route in a more reliable way.
Problem with identifying this information noted on discourse and at bug pi-hole/FTL#2525
How does this PR accomplish the above?:
Determine address and interface of default route by preceding 'via' and 'dev' fields in ip's json output, instead of field position in the plain text which is not always reliable.
Logs if unable to determine default gateway
Link documentation PRs if any are needed to support this PR:
N/A
By submitting this pull request, I confirm the following:
git rebase
)