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

Faced a problem with knockd not receiving packets because of ETHERTYPE_VLAN #89

Open
Regressor opened this issue May 24, 2023 · 1 comment

Comments

@Regressor
Copy link

Regressor commented May 24, 2023

Hi. I have a vps with ubuntu 22. I installed knockd using apt and can't get it working

I started it with debug and copied filter string. Then I started tcpdump with that string and got knocking packets.
knockd just prints listening on eth0 and nothing happens.

I downloaded sources from git added some debug prints and compiled them. Sniff triggered on incoming packets but exits at line 1639:

	if(ntohs(eth->ether_type) != ETHERTYPE_IP && ntohs(eth->ether_type) != ETHERTYPE_IPV6) {
		return;
	}

I added debug print and got ntohs(eth->ether_type) == ETHERTYPE_VLAN (0x8100)

There is no any vlan config in linux so I just can't disable it

Is there any way to get it working ?

@Regressor
Copy link
Author

Regressor commented May 24, 2023

Solved it for myself adding some dirty code:

    if(lltype == DLT_EN10MB) {
        eth = (struct ether_header*)packet;
        if(ntohs(eth->ether_type) != ETHERTYPE_IP && ntohs(eth->ether_type) != ETHERTYPE_IPV6 && ntohs(eth->ether_type) != ETHERTYPE_VLAN) {
            return;
        }

        int tag_size = 0;
        if (ntohs(eth->ether_type) == ETHERTYPE_VLAN) {
            tag_size = 4;
        }

        ip = (struct ip*)(packet + sizeof(struct ether_header) + tag_size);
        ip6 = (struct ip6_hdr*)(packet + sizeof(struct ether_header) + tag_size);

        int tag_size = 0;
        if (ntohs(eth->ether_type) == ETHERTYPE_VLAN) {
                tag_size = 4;
        }

        ip = (struct ip*)(packet + sizeof(struct ether_header) + tag_size);
        ip6 = (struct ip6_hdr*)(packet + sizeof(struct ether_header) + tag_size);

TDFKAOlli added a commit to TDFKAOlli/knock that referenced this issue Apr 4, 2024
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

1 participant