{"id":4490,"date":"2026-08-18T13:26:09","date_gmt":"2026-08-18T17:26:09","guid":{"rendered":"https:\/\/increasec.com\/?p=4490"},"modified":"2026-08-18T14:13:55","modified_gmt":"2026-08-18T18:13:55","slug":"port-knocking-for-security-w-knockd","status":"publish","type":"post","link":"https:\/\/increasec.com\/?p=4490","title":{"rendered":"Port Knocking for Security w KnockD"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Situation; we have a few cloud database instances, and the clients do not have static IP addresses.  The cloud service offers only a basic firewall; it does NOT support DNS entries, or Geo-filtering.  Cloud services like Digital Ocean don&#8217;t allow users to upload\/install dedicated firewall images like pfSense.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Proposed Solution; Allow clients to exempt themselves using port knocking,  like a combination lock<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Destination:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">apt install knockd iptables-persistent nano -Y<br>cp \/etc\/knockd.conf \/etc\/knockd.conf.example<br>iptables -A INPUT -p tcp &#8211;dport <strong>443 <\/strong>-j REJECT<br>       (this assumes the service you want to protect is on port 443 (HTTPS))<br>       (don&#8217;t recommend port 22 until you have verified the setup is working correctly, as you may lock yourself out)<br>systemctl start netfilter-persistent<br>netfilter-persistent save<br>netfilter-persistent reload<br>nano \/etc\/knockd.conf<br>      (edit the <strong>sequence<\/strong>, don&#8217;t use ports in order.  tcp is the default,  verify <strong>-I<\/strong>(not -A),  verify <strong>tcpflags <\/strong>= syn<br>       in the <strong>start_command <\/strong>line, verify the correct dport)<br>ip a<br>        (note your nic name)<br>nano \/etc\/default\/knockd<br>      START_KNOCCKD=1<br>           (1=on)<br>      KNOCKD_OPT=&#8221;-i <strong>eth0<\/strong>&#8220;<br>           (del starting #, replace eth0 with the nic name you looked up in a previous step)<br>systemctl start knockd<br>systemctl status knockd<br>systemctl enable knockd<br>      (this makes it start after every reboot)<br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Source:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">on linux use the knock command  ie   knock destination  9007 9999 9001          it gets installed with knockd<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">technically you don&#8217;t need a specific program to knock, it just makes it easier<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><br>On windows i have confirmed <a href=\"https:\/\/www.epinox.de\/en\/windows\/port-knocking-tool.html\">this <\/a>port knocking client works.  <br>Its a portable app so it can be downloaded and used even if the client doesn&#8217;t have administrator permissions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the cloud hosting has a separate firewall you will need to allow the tcp ports you are using for the knocking or the destination will never hear the knock sequence<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">iptables should work with docker,    <strong>docker bypasses ufw<\/strong>!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Situation; we have a few cloud database instances, and the clients do not have static IP addresses. The cloud service offers only a basic firewall; it does NOT support DNS&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[4],"class_list":["post-4490","post","type-post","status-publish","format-standard","hentry","category-uncategorised","tag-security"],"_links":{"self":[{"href":"https:\/\/increasec.com\/index.php?rest_route=\/wp\/v2\/posts\/4490","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/increasec.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/increasec.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/increasec.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/increasec.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4490"}],"version-history":[{"count":9,"href":"https:\/\/increasec.com\/index.php?rest_route=\/wp\/v2\/posts\/4490\/revisions"}],"predecessor-version":[{"id":4499,"href":"https:\/\/increasec.com\/index.php?rest_route=\/wp\/v2\/posts\/4490\/revisions\/4499"}],"wp:attachment":[{"href":"https:\/\/increasec.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/increasec.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4490"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/increasec.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}