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

Consider default route interface #44

Open
linutsdc opened this issue Jun 14, 2016 · 2 comments
Open

Consider default route interface #44

linutsdc opened this issue Jun 14, 2016 · 2 comments

Comments

@linutsdc
Copy link

I have a script that starts knockd which pulls the interface associated with the default route on the host. It's something along these lines:

ip route show | awk '$1=="default" && $2=="via" && $4=="dev" { print $5 }'

It pulls out he p5p1 from:

$ ip route show
default via 192.168.10.18 dev p5p1  proto static  metric 1024 
192.168.10.0/24 dev p5p1  proto kernel  scope link  src 192.168.10.13 
192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1 
205.203.130.5 via 192.168.10.18 dev p5p1  proto static  metric 1

Is that something that could be baked into knockd?

@o-jasper
Copy link

In practice, automatically detects the interface? Came here to ask the same thing. Maybe like eth0|wlan0 as input and it does whichever applicable.

@o-jasper
Copy link

o-jasper commented Jul 28, 2018

On my computer, added /etc/systemd/system/knockd-alt.service;

[Unit]
Description=Port-Knocking Daemon
After=network.target

[Service]
ExecStart=/usr/bin/knockd -i $(ip route show |grep default | cut -f 5 -d ' ')

[Install]
WantedBy=multi-user.target

-i overrides the config. But i'd rather the configuration file itself somehow supports it? It could support the @ notation, but would make more sense to make it refer to configuration files.

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

No branches or pull requests

2 participants