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

infer host interface from default route #8

Merged
merged 1 commit into from
Jun 22, 2021

Conversation

ibotty
Copy link
Contributor

@ibotty ibotty commented Jun 18, 2021

No description provided.

@ibotty
Copy link
Contributor Author

ibotty commented Jun 18, 2021

fixes #5

@ibotty
Copy link
Contributor Author

ibotty commented Jun 18, 2021

There could be more automagic 🦄: Say if the IP is set, try to find the corresponding interface. I don't know, whether that's really useful though, because if you explicitly set the IP you might be able to set the interface as well.

@@ -19,9 +19,27 @@ if [ ! -z "${KARP_DEBUG}" ] ; then
/usr/sbin/ucarp --help
fi

# if no explicit host interface is set, we determine it from the default route
if [ -z "$KARP_INTERFACE" ] ; then
KARP_INTERFACE="$(ip r | awk '/^default / { for(i=1; i<=NF; i++) if ($i == "dev") print $(i+1) }')"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice awk trick! :)

@immanuelfodor immanuelfodor merged commit 3777dd5 into immanuelfodor:master Jun 22, 2021
@immanuelfodor
Copy link
Owner

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.

2 participants