jvinet / knock

A port-knocking daemon
http://www.zeroflux.org/projects/knock
GNU General Public License v2.0
549 stars 113 forks source link

Added a new --interface option to knock #59

Open sasanj opened 5 years ago

sasanj commented 5 years ago

Hi, Recently I needed to knock a server from a client with multiple network interfaces which had different gateways, and since knock did not have a way to choose an interface, I added one. Hopefully, It is useful to others.

I implemented two ways to find the ip address of an interface. One, using ioctl which is the way knockd also uses, and the other one uses glibc getifaddrs. The idea is to refactor the code for finding the interface's address; in both knock and knockd. There is an option in configure (namely --disable-getifaddrs) to choose between each way.

Manual pages have also been changed, accordingly.

TDFKAOlli commented 5 years ago

@sasanj As seen in previous comment I tried to apply your patch on top of the ipv6 feature in my fork. My tests are fine so far, but I lack a proper IPv6 address and name resolution in my virtual machine to test all combinations of force 4 or 6 or not force in combination with the interface flag. Would be great if you could have a look. :smirk:

sasanj commented 5 years ago

@TDFKAOlli sorry for being late. This patch definitely won't work with IPv6. However, adding IPv6 support is simple. But I don't think it can be added to this repo. This knock is strictly IPv4.

TDFKAOlli commented 5 years ago

@sasanj O.k. I think you didn't get what I meant. Sorry, let me try again: I have taken your patch and applied it to my repository including IPv6. Then I extended it to support IPv6. I have tested it in my virtual machine having an routable IPv4 address but only having a link local IPv6. So I wondered if you have time to review https://github.com/TDFKAOlli/knock/commit/dc9f84efbf18469740e26bb9d2e1e7372fc3c107