<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.0.0">Jekyll</generator><link href="https://tunnelhound.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://tunnelhound.com/" rel="alternate" type="text/html" /><updated>2023-02-18T14:37:36+00:00</updated><id>https://tunnelhound.com/feed.xml</id><title type="html">TunnelHound</title><subtitle>TunnelHound is the easiest cloud VPN</subtitle><author><name>{&quot;name&quot;=&gt;nil, &quot;email&quot;=&gt;nil, &quot;twitter&quot;=&gt;nil}</name></author><entry><title type="html">Four reasons why business VPNs are still a necessity</title><link href="https://tunnelhound.com/network%20security/business/it/2020/12/17/why-business-vpns-are-still-necessary/" rel="alternate" type="text/html" title="Four reasons why business VPNs are still a necessity" /><published>2020-12-17T00:00:00+00:00</published><updated>2020-12-17T00:00:00+00:00</updated><id>https://tunnelhound.com/network%20security/business/it/2020/12/17/why-business-vpns-are-still-necessary</id><content type="html" xml:base="https://tunnelhound.com/network%20security/business/it/2020/12/17/why-business-vpns-are-still-necessary/">&lt;p&gt;The IT buzzword of the day in Silicon Valley is &lt;em&gt;zero-trust
networking&lt;/em&gt;, which refers to a model of corporate network security
where services are exposed directly to the web, and each secured
individually against outside attackers. Having gained notoriety for
their use at large corporations, such as Google, it may seem like the
noble VPN will soon find itself relegated to the junk heap.&lt;/p&gt;

&lt;p&gt;However, we think that VPNs will still be necessary for most
businesses, including yours. Here’s why.&lt;/p&gt;

&lt;h2 id=&quot;1-not-all-services-can-be-accessed-over-the-internet&quot;&gt;1. Not all services can be accessed over the internet&lt;/h2&gt;

&lt;p&gt;Google uses SSH, etc. Many businesses need more complicated protocols
such as RDP, etc, which are blocked on public networks.&lt;/p&gt;

&lt;p&gt;This is also why you need to make sure your VPN solution can ensure
connectivity, even in challenging network environments. For
example, &lt;a href=&quot;https://tunnelhound.com&quot;&gt;TunnelHound&lt;/a&gt; can maintain
connectivity, even when only insecure HTTP access is allowed.&lt;/p&gt;

&lt;h2 id=&quot;2-youre-stuck-using-legacy-services&quot;&gt;2. You’re stuck using legacy services&lt;/h2&gt;

&lt;p&gt;Large companies can bully their software vendors into adopting new
features that allow their services to be exposed directly to the
internet, or to build their own solution. Most companies cannot, and
are stuck relying on software that cannot be easily changed. A VPN and
firewall provides the perfect means to secure these services while
still allowing remote access.&lt;/p&gt;

&lt;h2 id=&quot;3-ensuring-connectivity-wherever-your-business-goes&quot;&gt;3. Ensuring connectivity wherever your business goes&lt;/h2&gt;

&lt;p&gt;As your business expands, chances are your employees will end up
traveling to places you may not have expected, including countries
that may limit their connectivity. VPNs provide an easy means around
this. By allowing an easy way for your employees to navigate their
internet traffic through your company’s routers, you can provide an
easy means for your employees to get around this when meeting
prospects in foreign jurisdictions.&lt;/p&gt;

&lt;h2 id=&quot;4-monitoring-and-compliance&quot;&gt;4. Monitoring and compliance&lt;/h2&gt;

&lt;p&gt;If your business is involved in certain industries, it may be
necessary to meet certain compliance requirements to maintain best
practices. VPNs provide a way to centralize these policies so that you
remain compliant, instead of leaving it up to chance. By allowing IT
administrators to remotely configure how employee internet traffic is
routed, a VPN makes sure that data in motion remains compliant with
relevant laws and industry requirements.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;</content><author><name>{&quot;name&quot;=&gt;nil, &quot;email&quot;=&gt;nil, &quot;twitter&quot;=&gt;nil}</name></author><summary type="html">The IT buzzword of the day in Silicon Valley is zero-trust networking, which refers to a model of corporate network security where services are exposed directly to the web, and each secured individually against outside attackers. Having gained notoriety for their use at large corporations, such as Google, it may seem like the noble VPN will soon find itself relegated to the junk heap.</summary></entry><entry><title type="html">Why NFTables is better than IPTables, and how to switch</title><link href="https://tunnelhound.com/tunnelhound/internals/2020/12/04/why-nftables-is-better-than-iptables/" rel="alternate" type="text/html" title="Why NFTables is better than IPTables, and how to switch" /><published>2020-12-04T00:00:00+00:00</published><updated>2020-12-04T00:00:00+00:00</updated><id>https://tunnelhound.com/tunnelhound/internals/2020/12/04/why-nftables-is-better-than-iptables</id><content type="html" xml:base="https://tunnelhound.com/tunnelhound/internals/2020/12/04/why-nftables-is-better-than-iptables/">&lt;p&gt;If you’ve spent much time around the Linux networking stack, chances are you’ve heard of
IPTables. If you haven’t, IPTables is the framework that decides what to do with incoming network
packets. It can be used to set up everything from simple firewalls up until complicated stateful
routers and NATs. First released in 1998, this venerable software package has powered many networks
for a venerable two decades.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://tunnelhound.com&quot;&gt;TunnelHound&lt;/a&gt; does lots of routing. IPTables would have been the easy,
obvious choice for constructing the TunnelHound state machine. However, like a lot of legacy software,
IPTables has its limits that can make it difficult to scale to the kinds of routing problems many
organizations face today. In 2014, a new filtering package &lt;a href=&quot;http://nftables.org/&quot;&gt;NFTables&lt;/a&gt; was
merged into the Linux kernel meant to fix some of these limits. Six years later, it’s safe to say
that NFTables is the future of packet filtering. Here’s what you need to know and why you ought to
switch.&lt;/p&gt;

&lt;h1 id=&quot;differences-between-iptables-and-nftables&quot;&gt;Differences between IPTables and NFTables&lt;/h1&gt;

&lt;p&gt;Before we start on the differences between NFTables and IPTables, it’s worth pointing out the two
are more similar than different. Both perform the same basic task – filtering packets that arrive
at a Linux host and deciding what to do with it. Both frameworks offer CLI tools to interact with
the framework (&lt;code class=&quot;highlighter-rouge&quot;&gt;iptables&lt;/code&gt; for IPTables and &lt;code class=&quot;highlighter-rouge&quot;&gt;nft&lt;/code&gt; for NFTables). As they say, the differences are in
the details, and, as we’ll see, these differences matter a lot when it comes to building performant
and scalable filtering applications.&lt;/p&gt;

&lt;h2 id=&quot;difference-1-syntax&quot;&gt;Difference 1: Syntax&lt;/h2&gt;

&lt;p&gt;IPTables offers a basic command-line interface to interact with the kernel. Rules are created by
 calling the &lt;code class=&quot;highlighter-rouge&quot;&gt;iptables&lt;/code&gt; command using a &lt;code class=&quot;highlighter-rouge&quot;&gt;getopt_long()&lt;/code&gt; based parser.&lt;/p&gt;

&lt;p&gt;NFTables also allows you to specify rules on the command line, but with its own custom EDSL
instead. This makes rule specifications more concise.&lt;/p&gt;

&lt;p&gt;Here’s an example IPTables based rule to drop any packets coming in on port 80.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;iptables &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; INPUT &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; tcp &lt;span class=&quot;nt&quot;&gt;--destination-port&lt;/span&gt; 80 &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; DROP
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here’s the corresponding NFTables rule.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nft add rule inet firewall filter tcp dport 80 drop
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Some of these syntactic changes allow you to significantly reduce complexity. For example, suppose
you want to disallow TCP ports for SSH, HTTP, and HTTPS. In IPTables, this would require you to make
three separate rules &lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;. In NFTables, you can specify values as &lt;em&gt;sets&lt;/em&gt;. This is not shorthand for
creating multiple rules. Rather it creates one rule with multiple disjoint matchers.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nft add rule inet firewall filter tcp dport &lt;span class=&quot;s1&quot;&gt;'{80, 443, 22}'&lt;/span&gt; drop
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;As another added bonus, you can specify multiple actions in the same rule. This functionality is
much more difficult than in IPTables and would require you to make another table and add a JUMP
action. For example, to both drop and count the dropped packets. For example, to accept traffic from
IP network &lt;code class=&quot;highlighter-rouge&quot;&gt;1.2.3.0/24&lt;/code&gt; on port 25, count the number of packets received, and log new connections,
you can add one simple rule.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nft add rule inet firewall &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  filter ip saddr 1.2.3.0/24 tcp dport 25 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
         counter &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;&lt;span class=&quot;c&quot;&gt;# Count all packets arriving at port 25&lt;/span&gt;
         accept  &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;&lt;span class=&quot;c&quot;&gt;# Accept the packet too&lt;/span&gt;
         counter ct state new &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;&lt;span class=&quot;c&quot;&gt;# When the connection is new&lt;/span&gt;
           log prefix &lt;span class=&quot;s2&quot;&gt;&quot;New SMTP connection&quot;&lt;/span&gt; accept &lt;span class=&quot;c&quot;&gt;# Log it&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In the rule above, there are three actions: &lt;code class=&quot;highlighter-rouge&quot;&gt;counter&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;accept&lt;/code&gt;, and &lt;code class=&quot;highlighter-rouge&quot;&gt;log&lt;/code&gt;. The rule is evaluated
left-to-right, so all packets from the given source address to TCP port 25 trigger the &lt;code class=&quot;highlighter-rouge&quot;&gt;counter&lt;/code&gt; and
&lt;code class=&quot;highlighter-rouge&quot;&gt;accept&lt;/code&gt; rules, which count the packet and accept it, respectively. The latter part of the rule only
matches packets that represent new connections. If the connection is new, then the packet is logged
as well.&lt;/p&gt;

&lt;h2 id=&quot;difference-2-complexity&quot;&gt;Difference 2: Complexity&lt;/h2&gt;

&lt;p&gt;NFTables is a lot simpler than IPTables. Whereas IPTables comes with many different table sets, one
for each protocol (&lt;code class=&quot;highlighter-rouge&quot;&gt;iptables&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;ip6tables&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;arptables&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;ebtables&lt;/code&gt;, etc), NFTables has no built-in
tables. A major performance bottlenecks with IPTables was that executing rulesets for empty tables
actually took up a surprisingly large (read: non-zero) amount of time. This means that simply
loading IPTables in the kernel could slow down your networking stack.&lt;/p&gt;

&lt;p&gt;NFTables on the other hand has no built-in tables. Instead, tables are constructed by the
administrator, and then “hooked” into various parts of the networking stack. For example, in the
command-line above, we blocked incoming TCP connections on port 80 by adding a rule to the &lt;code class=&quot;highlighter-rouge&quot;&gt;INPUT&lt;/code&gt;
table, which is a pre-defined table provided by IPTables. The &lt;code class=&quot;highlighter-rouge&quot;&gt;nft&lt;/code&gt; command-line above assumed we
have a &lt;em&gt;chain&lt;/em&gt; named &lt;code class=&quot;highlighter-rouge&quot;&gt;filter&lt;/code&gt; in the &lt;code class=&quot;highlighter-rouge&quot;&gt;firewall&lt;/code&gt; &lt;em&gt;table&lt;/em&gt; of the &lt;code class=&quot;highlighter-rouge&quot;&gt;inet&lt;/code&gt; “family”. By itself, this
table and chain won’t do anything. It has to be added as a hook into the input part of the
networking stack.&lt;/p&gt;

&lt;p&gt;For example, to add the tables above, we have to run the following &lt;code class=&quot;highlighter-rouge&quot;&gt;nft&lt;/code&gt; commands.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nft &lt;span class=&quot;s1&quot;&gt;'add table inet firewall'&lt;/span&gt;
nft &lt;span class=&quot;s1&quot;&gt;'add chain inet firewall filter { type filter hook input priority 0; }`
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The hook part says that this chain is a &lt;code class=&quot;highlighter-rouge&quot;&gt;filter&lt;/code&gt; type chain will be called whenever an input packet
arrives. The best part is that before you add this chain, no extra execution time is spent in the
kernel when processing input packets.&lt;/p&gt;

&lt;h2 id=&quot;difference-4-efficiency&quot;&gt;Difference 4: Efficiency&lt;/h2&gt;

&lt;p&gt;In IPTables, the rule set is maintained as a binary blob. This blob gets read from the kernel,
manipulated, and written back atomically every time you invoke the &lt;code class=&quot;highlighter-rouge&quot;&gt;iptables&lt;/code&gt; command. If changing
rules often, this can be a problem, because the time complexity scales linearly with the size of the
rules. NFTables uses a linked-list based approach to store rules, so inserting and deleting new
rules takes constant time.&lt;/p&gt;

&lt;h2 id=&quot;difference-5-upgrades&quot;&gt;Difference 5: Upgrades&lt;/h2&gt;

&lt;p&gt;In IPTables, each rule was a representation of functionality provided by the kernel. For example,
the &lt;code class=&quot;highlighter-rouge&quot;&gt;iptables&lt;/code&gt; rule above to match incoming traffic on port 80 was translated into a kernel object
representing the rule “Match TCP traffic on port 80.” NFTables takes a much lower-level
approach. Instead of providing rules to the kernel, NFTables rules are compiled into a &lt;em&gt;bytecode&lt;/em&gt;
format which can match on any field in the packet headers. This means that rule functionality is
actually determined in userspace. The corresponding NFTables rule above would be translated into
bytecode that said something like “examine the 16-bit field at offset XXX in the header and match if
it is 80 in network byte order,” where XXX is the offset of the destination port in the combined
TCP/IP header. This may seem more complex, but actually it simplifies things quite a bit.&lt;/p&gt;

&lt;p&gt;Most importantly, in IPTables, if you wanted access to a new rule type, this would often require a
kernel upgrade. Although your &lt;code class=&quot;highlighter-rouge&quot;&gt;iptables&lt;/code&gt; command may support a rule, if your kernel version didn’t
match, you would be unable to use it. This could be a major problem for some implementations because
distributions often ship a several year-old kernel for stability reasons. You were stuck with the
choice to accept a potentially unstable kernel you had to build yourself, or to resign to not using
the new features.&lt;/p&gt;

&lt;p&gt;With NFTables, however, this problem is gone. Simply updating the &lt;code class=&quot;highlighter-rouge&quot;&gt;nftables&lt;/code&gt; package is enough to
give you access to the latest features. This is good news to system administrators: kernel upgrades
necessitate downtime, or significant planning, whereas userspace changes are much more easily
accomplished.&lt;/p&gt;

&lt;h2 id=&quot;difference-6-ipv4-and-ipv6-interoperability&quot;&gt;Difference 6: IPv4 and IPv6 interoperability&lt;/h2&gt;

&lt;p&gt;In IPTables, rules for IPv4 and IPv6 had to be specified using two separate commands &lt;code class=&quot;highlighter-rouge&quot;&gt;iptables&lt;/code&gt; and
&lt;code class=&quot;highlighter-rouge&quot;&gt;ip6tables&lt;/code&gt;. NFTables lets you use the pseudo &lt;code class=&quot;highlighter-rouge&quot;&gt;inet&lt;/code&gt; protocol to write rules that correspond to
either protocol. For example, the &lt;code class=&quot;highlighter-rouge&quot;&gt;nft&lt;/code&gt; command:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nft add rule inet firewall filter tcp dport &lt;span class=&quot;s1&quot;&gt;'{80, 443, 22}'&lt;/span&gt; drop
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Drops TCP traffic on the given ports for both IPv4 and IPv6. To write a rule specific to one
protocol, you can specify either protocol specifically.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nft add rule ip firewall filter tcp dport 80 drop
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;would only block HTTP traffic on IPv4.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nft add rule ip6 firewall filter tcp dport 443 drop
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;would correspondingly block HTTPS traffic on IPv6 only.&lt;/p&gt;

&lt;h2 id=&quot;difference-7-sets&quot;&gt;Difference 7: Sets&lt;/h2&gt;

&lt;p&gt;Suppose you wanted to create an automatic IP blacklisting service (like fail2ban) using
IPTables. Every time you wanted to ban an IP, you would add another rule:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;iptables &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; INPUT &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; banned.ip &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; DROP
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Because of the efficiency problems identified above, for large public-facing services, this banning
procedure takes longer and longer the more addresses you add. Moreover, the networking performance
degrades as more rules are added to the rule set &lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;As stated above, NFTables allows O(1) rule insertion, but if that were all, it would still suffer
from the linear-scaling rule execution time.&lt;/p&gt;

&lt;p&gt;Fortunately, NFTables provides &lt;em&gt;sets&lt;/em&gt;, a typed collection of objects. Because sets are based on hash
tables, they add little overhead to our rules. We began to approach sets above when we specified
filters that matched more than one port. For example, in the command&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nft add rule inet firewall filter tcp dport &lt;span class=&quot;s1&quot;&gt;'{80, 443, 22}'&lt;/span&gt; drop
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;the part in braces represents an &lt;em&gt;anonymous set&lt;/em&gt; representing three ports. NFTables adds the ability
to name sets, and then add and remove elements of sets at runtime.&lt;/p&gt;

&lt;p&gt;For example, to add a set named &lt;code class=&quot;highlighter-rouge&quot;&gt;blacklisted_ips&lt;/code&gt; that can contain IP addresses,&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nft &lt;span class=&quot;s1&quot;&gt;'add set ip firewall blacklisted_ip4s { type ipv4_addr; }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now, we can add a rule to block &lt;em&gt;any&lt;/em&gt; IP in the named set.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nft add rule ip firewall filter ip saddr @blacklisted_ip4s drop
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Upon set creation above, the set is empty. Instead of adding a new rule whenever our service wanted
to block an IP, we can now add elements to the set.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nft add element ip firewall blacklisted_ip4s 44.92.123.21, 123.231.132.213
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Or remove them:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nft delete element ip firewall blacklisted_ip4s 44.92.123.21
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;No more linear scaling for repeated rules! NFTables rocks for scalability.&lt;/p&gt;

&lt;h2 id=&quot;difference-8-maps&quot;&gt;Difference 8: Maps!&lt;/h2&gt;

&lt;p&gt;If that were not amazing enough, NFTables extends sets yet again by supporting mappings. For
example, suppose you wanted to build a public-facing endpoint that internally routed traffic to
different hosts (with only internal addresses) based on the TCP port. Suppose your HTTP server is at
address &lt;code class=&quot;highlighter-rouge&quot;&gt;192.168.1.100&lt;/code&gt; and your SSH server at &lt;code class=&quot;highlighter-rouge&quot;&gt;192.168.1.102&lt;/code&gt; in your private address space. In
IPTables, you’d again have to write two separate rules for this source NAT. In NFTables, you can
just write a mapping (below, we’ve assumed you’ve created and hooked up the appropriate tables and
chains for
&lt;a href=&quot;https://wiki.nftables.org/wiki-nftables/index.php/Performing_Network_Address_Translation_(NAT)&quot;&gt;NAT&lt;/a&gt;).&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nft add rule ip nat prerouting dnat tcp dport &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; 80: 192.168.1.100, 22: 192.168.1.102 &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Just like sets, we can even create named maps, and then modify elements at runtime. This would allow
you to set up a rule like the above where you can change the address for each port at runtime (for
example, when bringing hosts up and down).&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nft &lt;span class=&quot;s1&quot;&gt;'add map ip nat porttoip { type inet_service: ipv4_addr; }'&lt;/span&gt;
nft &lt;span class=&quot;s1&quot;&gt;'add element ip nat porttoip { 80: 192.168.1.100 }'&lt;/span&gt;
nft &lt;span class=&quot;s1&quot;&gt;'add rule ip nat postrouting dnat tcp dport @porttoip'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;switching-to-nftables&quot;&gt;Switching to NFTables&lt;/h1&gt;

&lt;p&gt;Most major distributions have support for NFTables. Some, like Debian, use NFTables by default
already. Here are guides for various distributions:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.liquidweb.com/kb/how-to-install-nftables-in-ubuntu/&quot;&gt;Ubuntu&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://wiki.archlinux.org/index.php/nftables#Installation&quot;&gt;Arch&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://wiki.debian.org/nftables&quot;&gt;Debian&lt;/a&gt; – default packet filtering framework starting from Buster&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://wiki.gentoo.org/wiki/Nftables&quot;&gt;Gentoo&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.fedoraproject.org/en-US/fedora/f32/release-notes/sysadmin/Networking/&quot;&gt;Fedora&lt;/a&gt; – already installed by default&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The &lt;code class=&quot;highlighter-rouge&quot;&gt;xtables-translate&lt;/code&gt; commands let you translate &lt;code class=&quot;highlighter-rouge&quot;&gt;iptables&lt;/code&gt;/&lt;code class=&quot;highlighter-rouge&quot;&gt;ip6tables&lt;/code&gt;/&lt;code class=&quot;highlighter-rouge&quot;&gt;ebtables&lt;/code&gt;/etc rules into
&lt;code class=&quot;highlighter-rouge&quot;&gt;nft&lt;/code&gt;’s accepted format. Here’s an example from the NFTables wiki:&lt;/p&gt;

&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;iptables-translate &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; INPUT &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; tcp &lt;span class=&quot;nt&quot;&gt;--dport&lt;/span&gt; 22 &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; conntrack &lt;span class=&quot;nt&quot;&gt;--ctstate&lt;/span&gt; NEW &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; ACCEPT
&lt;span class=&quot;go&quot;&gt;nft add rule ip filter INPUT tcp dport 22 ct state new counter accept

&lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;ip6tables-translate &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt; FORWARD &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; eth0 &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; eth3 &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; udp &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; multiport &lt;span class=&quot;nt&quot;&gt;--dports&lt;/span&gt; 111,222 &lt;span class=&quot;nt&quot;&gt;-j&lt;/span&gt; ACCEPT
&lt;span class=&quot;go&quot;&gt;nft add rule ip6 filter FORWARD iifname eth0 oifname eth3 meta l4proto udp udp dport { 111,222} counter accept
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If you have an existing &lt;code class=&quot;highlighter-rouge&quot;&gt;iptables&lt;/code&gt; ruleset installed, you can translate the entire ruleset:&lt;/p&gt;

&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;iptables-save &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; rules.txt &lt;span class=&quot;c&quot;&gt;# Save all iptables rules to a file&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;iptables-restore-translate &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; rules.txt &lt;span class=&quot;c&quot;&gt;# Translate all rules in the file to nftables&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Note that if you decide to switch to &lt;code class=&quot;highlighter-rouge&quot;&gt;nftables&lt;/code&gt; it’s best to purge your &lt;code class=&quot;highlighter-rouge&quot;&gt;iptables&lt;/code&gt; rules and unload
the kernel module. Using both frameworks is possible, but can lead to strange bugs. You can use
&lt;code class=&quot;highlighter-rouge&quot;&gt;iptables -X&lt;/code&gt; to delete all non-default chains, and &lt;code class=&quot;highlighter-rouge&quot;&gt;iptables -F&lt;/code&gt; to reset all chains. Then unload
&lt;code class=&quot;highlighter-rouge&quot;&gt;iptables&lt;/code&gt; by using &lt;code class=&quot;highlighter-rouge&quot;&gt;modprobe -r iptables&lt;/code&gt;.&lt;/p&gt;

&lt;h1 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h1&gt;

&lt;p&gt;NFTables is the new kid on the block, with significant advantages over IPTables for packet
filtering. What it lacks in years is more than made up for by the extended functionality, the ease
of use, and the independence from the underlying kernel. Nevertheless, many users haven’t yet made
the switch. We hope that this guide has inspired you to take NFTables for a spin!&lt;/p&gt;

&lt;h1 id=&quot;more-information&quot;&gt;More information&lt;/h1&gt;

&lt;p&gt;We only touched the surface of what NFTables is capable of in this post. Over the next few months,
we’ll be posting more about how we use NFTables to enable certain features
in &lt;a href=&quot;https://tunnelhound.com&quot;&gt;TunnelHound&lt;/a&gt;. In the meantime, you can browse
NFTables’s &lt;a href=&quot;https://wiki.nftables.org&quot;&gt;extensive documentation&lt;/a&gt;&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;We’d like to know what you think of NFTables? Questions? Are there advantages of IPTables we didn’t
mention? Let us know on &lt;a href=&quot;https://twitter.com/getwirehound&quot;&gt;social media&lt;/a&gt;
or &lt;a href=&quot;mailto:support@tunnelhound.com&quot;&gt;reach out to us&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Unless you use the &lt;code class=&quot;highlighter-rouge&quot;&gt;multiport&lt;/code&gt; matcher, but that’s limited to fifteen ports. Moreover,
NFTables lets you do this with any kind of parameter, not just ports. For example, you can only
accept certain ICMP requests:&lt;/p&gt;

      &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nft &lt;span class=&quot;s1&quot;&gt;'add rule inet firewall ip protocol icmp icmp type {echo-request, redirect} accept'&lt;/span&gt;
nft &lt;span class=&quot;s1&quot;&gt;'add rule inet firewall ip protocol icmp drop
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;      &lt;/div&gt;

      &lt;p&gt;This example drops all ICMP packet types unless they are pings (&lt;code class=&quot;highlighter-rouge&quot;&gt;echo-request&lt;/code&gt;) or port
redirects (&lt;code class=&quot;highlighter-rouge&quot;&gt;redirect&lt;/code&gt;). &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;This is because IPTables processes rules in order. The more rules in the ruleset, the longer
the filtering will take &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Some cool features we have not even mentioned
are &lt;a href=&quot;https://wiki.nftables.org/wiki-nftables/index.php/Concatenations&quot;&gt;concatenations&lt;/a&gt;, which
extend maps even
further; &lt;a href=&quot;https://wiki.nftables.org/wiki-nftables/index.php/Intervals&quot;&gt;intervals&lt;/a&gt;, which
simplify adding multiple elements to sets and maps;
and &lt;a href=&quot;https://wiki.nftables.org/wiki-nftables/index.php/Stateful_objects&quot;&gt;stateful objects&lt;/a&gt;,
which let you build more sophisticated counters and quota systems. &lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;</content><author><name>{&quot;name&quot;=&gt;nil, &quot;email&quot;=&gt;nil, &quot;twitter&quot;=&gt;nil}</name></author><summary type="html">If you’ve spent much time around the Linux networking stack, chances are you’ve heard of IPTables. If you haven’t, IPTables is the framework that decides what to do with incoming network packets. It can be used to set up everything from simple firewalls up until complicated stateful routers and NATs. First released in 1998, this venerable software package has powered many networks for a venerable two decades.</summary></entry><entry><title type="html">Setting up a WireGuard VPN on Amazon EC2 to access a private VPC</title><link href="https://tunnelhound.com/tunnelhound/aws/howto/2020/11/28/setting-up-wireguard-on-aws-vpc-with-wirehound/" rel="alternate" type="text/html" title="Setting up a WireGuard VPN on Amazon EC2 to access a private VPC" /><published>2020-11-28T00:00:00+00:00</published><updated>2020-11-28T00:00:00+00:00</updated><id>https://tunnelhound.com/tunnelhound/aws/howto/2020/11/28/setting-up-wireguard-on-aws-vpc-with-wirehound</id><content type="html" xml:base="https://tunnelhound.com/tunnelhound/aws/howto/2020/11/28/setting-up-wireguard-on-aws-vpc-with-wirehound/">&lt;p&gt;These days, many businesses choose to host their entire infrastructure on a cloud provider, like
Amazon. This has a number of benefits, such as the ability to quickly scale up or down or reductions
in initial capex. One of the difficulties with cloud environments is offering secured access to
private cloud resource with VPNs. The native cloud solutions, like Amazon VPN, can be costly. For
example, running an Amazon Client VPN costs $0.15/hr and then an additional $0.05/hr for every
client connected. For a small company with four employees connected 8 hours every weekday, this can
add up to almost 200 / month. If your employees keep their laptops on all day, costs can quickly
escalate to several hundreds of dollars a month. That’s not to mention bandwidth costs.&lt;/p&gt;

&lt;p&gt;The main way around this is to set up an EC2 server as a VPN gateway. There are a few options here,
such as OpenVPN, but the latest entrant into the arena is &lt;a href=&quot;https://wireguard.com&quot;&gt;WireGuard®&lt;/a&gt;, a
Linux native VPN, that is easy to set up, fast, and cryptographically secure.&lt;/p&gt;

&lt;p&gt;Unfortunately, WireGuard can be a bit of a pain to set up properly, and unlike more established
players such as OpenVPN, it can be difficult to integrate into a cloud environment without
developing custom solutions.&lt;/p&gt;

&lt;p&gt;In this HOWTO, we’ll go through the steps of setting up an Amazon VPC (virtual private cloud) and
then securing external access to private resources by setting up a WireGuard gateway. We’ll create
the following network topology:&lt;/p&gt;

&lt;p&gt;The two hosts are named Host A and Host B. Host B will only have a private IP and be inaccessible
from the internet. Host A will have both a public and private IP, but will not be accessible via SSH
except through the private IP address. Finally, Host C will serve as a WireGuard gateway and offer
configured clients the ability to connect to Host A or B via the private IP.&lt;/p&gt;

&lt;p&gt;In order to simplify set up and offer an easy management portal to network administrators and a
self-service portal to network users, we’ll use &lt;a href=&quot;https://tunnelhound.com&quot;&gt;TunnelHound&lt;/a&gt;, a WireGuard
portal software that comes with
pre-built &lt;a href=&quot;https://docs.tunnelhound.com/install/cloud/aws&quot;&gt;Amazon AMIs&lt;/a&gt;
and &lt;a href=&quot;https://hub.docker.com/repository/docker/tunnelhound/tunnelhound&quot;&gt;Docker images&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let’s get started!&lt;/p&gt;

&lt;h1 id=&quot;requirements&quot;&gt;Requirements&lt;/h1&gt;

&lt;p&gt;To get started with this HOWTO, you will need the following:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;An Amazon Web Services account&lt;/li&gt;
  &lt;li&gt;Access to the AWS web console&lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;creating-a-vpc&quot;&gt;Creating a VPC&lt;/h1&gt;

&lt;p&gt;The first step in creating the topology above is to create an Amazon VPC. Our VPC will exist in the
&lt;code class=&quot;highlighter-rouge&quot;&gt;172.16.0.0/20&lt;/code&gt;, which provides 4094 addresses and up to 4096 distinct subnets.&lt;/p&gt;

&lt;p&gt;We’ll assign subnets &lt;code class=&quot;highlighter-rouge&quot;&gt;172.16.0.0/24&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;172.16.1.0/24&lt;/code&gt; to the private hosts in the Amazon
cloud. Subnet &lt;code class=&quot;highlighter-rouge&quot;&gt;172.16.2.0/24&lt;/code&gt; will be assigned to VPN clients. This provides 253 private host
addresses and 253 VPN addresses (one is consumed by the WireGuard gateway on each subnet).&lt;/p&gt;

&lt;p&gt;To create an Amazon VPC, navigate to
the &lt;a href=&quot;https://console.aws.amazon.com/vpc/&quot;&gt;Amazon VPC console&lt;/a&gt;. Take note of the region in the upper
right hand corner to make sure all resources are created in the proper Amazon region.&lt;/p&gt;

&lt;p&gt;To create the VPC, click on the VPC link on the console.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/vpc-dashboard-link.png&quot; alt=&quot;The VPC button&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Then, click on the orange &lt;strong&gt;Create VPC&lt;/strong&gt; button in the upper right-hand corner. This will bring up
the following page.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/create-vpc-form.png&quot; alt=&quot;The Create VPC form&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Fill in the details as follows:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Name tag&lt;/strong&gt; – Any name is fine here&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;IPv4 CIDR block&lt;/strong&gt; – Type in &lt;code class=&quot;highlighter-rouge&quot;&gt;172.16.0.0/20&lt;/code&gt; here, which is the CIDR block of the private network we’re creating.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;IPv6 CIDR block&lt;/strong&gt; – Leave this blank for now. You can add IPv6 support into this VPC if you’d like, but TunnelHound currently doesn’t work with IPv6&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Tenancy&lt;/strong&gt; – Don’t change this&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now click the &lt;strong&gt;Create VPC&lt;/strong&gt; button&lt;/p&gt;

&lt;h2 id=&quot;creating-the-subnets&quot;&gt;Creating the subnets&lt;/h2&gt;

&lt;p&gt;Our VPC will consist of two subnets. First, the subnet &lt;code class=&quot;highlighter-rouge&quot;&gt;172.16.0.0/24&lt;/code&gt; which is for our private
hosts running on Amazon EC2. Secondly, subnet &lt;code class=&quot;highlighter-rouge&quot;&gt;172.16.1.0/24&lt;/code&gt; will be for our EC2 hosts that need
both public and private addresses. Finally, &lt;code class=&quot;highlighter-rouge&quot;&gt;172.16.1.0/24&lt;/code&gt; will be for our client connections.&lt;/p&gt;

&lt;p&gt;Since only the &lt;code class=&quot;highlighter-rouge&quot;&gt;172.16.0.0/24&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;172.16.1.0/24&lt;/code&gt; subnets will contain Amazon resources, we’ll only
need to create an AWS subnet for this subnet. The other subnet will be managed by a route in our
Amazon VPC that will direct all traffic to the WireGuard gateway.&lt;/p&gt;

&lt;p&gt;To create the private subnet, click the &lt;strong&gt;Subnets&lt;/strong&gt; link in the Amazon VPC console sidebar.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/vpc-subnets-link-sidebar.png&quot; alt=&quot;The VPC subnets link&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Then click the &lt;strong&gt;Create Subnet&lt;/strong&gt; button. In the subsequent form, choose the VPC you just created in
the step above.&lt;/p&gt;

&lt;p&gt;Create the first subnet by filling in the form as follows:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/vpc-subnet-1.png&quot; alt=&quot;The VPC subnet form&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The, create the second subnet, by clicking the &lt;strong&gt;Add new subnet&lt;/strong&gt; button. Then, add the details for
the second public subnet.&lt;/p&gt;

&lt;p&gt;Fill in the following details, then click &lt;strong&gt;Create subnet&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/vpc-subnet-2.png&quot; alt=&quot;The second subnet details&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;adding-an-internet-gateway&quot;&gt;Adding an internet gateway&lt;/h2&gt;

&lt;p&gt;At this point, our network exists, but cannot access the internet. To access the internet from a
VPC, we need
an &lt;a href=&quot;https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html&quot;&gt;internet gateway&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We can create an internet gateway, by navigating to the &lt;strong&gt;Internet Gateways&lt;/strong&gt; console from the
Amazon VPC navigation bar at the left. Click the &lt;strong&gt;Create internet gateway&lt;/strong&gt; button, choose a name
for the gateway, and save the gateway. Now, attach the gateway to the VPC created above, by clicking
on the &lt;strong&gt;Actions&lt;/strong&gt; dropdown, and selecting &lt;strong&gt;Attach to VPC&lt;/strong&gt;. In the selection box, type in the VPC
ID of the VPC created above. Then click the button to attach the gateway.&lt;/p&gt;

&lt;h2 id=&quot;route-table-setup&quot;&gt;Route Table setup&lt;/h2&gt;

&lt;p&gt;Now we’ll set up the routing table for our VPC. Again, navigate to the &lt;strong&gt;Route Tables&lt;/strong&gt; console on
the Amazon VPC navigation bar at the left of the page. There will be a routing table already
associated with your VPC which you can find by filtering the list for your VPC id.&lt;/p&gt;

&lt;p&gt;Go to the &lt;strong&gt;Subnet Associations&lt;/strong&gt; tab, and click &lt;strong&gt;Edit Subnet Associations&lt;/strong&gt;. Choose both the
subnets you configured above, and click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/route-table-subnet.png&quot; alt=&quot;Route table subnet setup&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now, in the &lt;strong&gt;Routes&lt;/strong&gt; tab, we’ll need to direct all internet traffic to the internet gateway. Click
the &lt;strong&gt;Edit Routes&lt;/strong&gt; button, and then the &lt;strong&gt;Add Route&lt;/strong&gt; button. In the &lt;strong&gt;Destination&lt;/strong&gt; box, enter
&lt;code class=&quot;highlighter-rouge&quot;&gt;0.0.0.0/0&lt;/code&gt;. In the &lt;strong&gt;Target&lt;/strong&gt; selection box, first choose &lt;strong&gt;Internet gateway&lt;/strong&gt;, then select the
gateway created above. Click &lt;strong&gt;Save Routes&lt;/strong&gt; to propagate the route information.&lt;/p&gt;

&lt;h2 id=&quot;creating-the-hosts&quot;&gt;Creating the hosts&lt;/h2&gt;

&lt;p&gt;Now, it’s time to create Host A and B. We’ll be using an Amazon Linux AMI for these hosts. Navigate
to the &lt;a href=&quot;https://console.aws.amazon.com/ec2/&quot;&gt;EC2 dashboard&lt;/a&gt;. Then, choose &lt;strong&gt;Launch instance&lt;/strong&gt; to
start the Launch instance wizard.&lt;/p&gt;

&lt;p&gt;Choose the Amazon Linux machine image, which is usually at the top of the AMI list. Choose an
appropriate instance size. For this tutorial, &lt;code class=&quot;highlighter-rouge&quot;&gt;t2.nano&lt;/code&gt; is probably appropriate.&lt;/p&gt;

&lt;p&gt;In the &lt;strong&gt;Configure Instance&lt;/strong&gt; tab, choose the VPC we created above (you can search it by name). Choose
the public subnet and make sure you have asked for a public IP to be assigned to the instance.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/host-a-details.png&quot; alt=&quot;The instance details tab for Host A&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In the &lt;strong&gt;Add Tags&lt;/strong&gt; tab, you can tag this image with the name &lt;strong&gt;Host A&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In the &lt;strong&gt;Configure Security Group&lt;/strong&gt; tab, create a new security group and grant SSH access via the
internal subnet.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/vpc-ssh-only-security-group.png&quot; alt=&quot;Example security group setup for internal SSH access only&quot; /&gt;&lt;/p&gt;

&lt;p&gt;You can now click &lt;strong&gt;Review and Launch&lt;/strong&gt; make sure to choose an SSH key you have access to.&lt;/p&gt;

&lt;p&gt;Now, for Host B, choose the same as Host A, except place Host B in the &lt;em&gt;private subnet&lt;/em&gt; we
configured above and do not ask for a public IP. Re-use the security group above.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/host-b-details.png&quot; alt=&quot;The instance details tab for Host B&quot; /&gt;&lt;/p&gt;

&lt;h1 id=&quot;setting-up-wireguard-and-connecting-via-ssh&quot;&gt;Setting up WireGuard and connecting via SSH&lt;/h1&gt;

&lt;p&gt;If you notice now, you can’t SSH into either Host A or Host B. This is because SSH is only allowed
for connections coming from the private VPC network, which your computer is not on. We’ll now set up
a TunnelHound instance to secure external traffic into the internal network.&lt;/p&gt;

&lt;h2 id=&quot;launching-the-tunnelhound-service&quot;&gt;Launching the TunnelHound service&lt;/h2&gt;

&lt;p&gt;TunnelHound provides pre-built AMIs available in most AWS regions. To launch a TunnelHound instance,
select the appropriate AMI from
the &lt;a href=&quot;https://docs.tunnelhound.com/install/cloud/aws&quot;&gt;list here&lt;/a&gt;. Click the &lt;strong&gt;Launch AMI…&lt;/strong&gt; link
next to the appropriate region to automatically be redirected to the launch instance wizard.&lt;/p&gt;

&lt;p&gt;Setup for the VPN appliance is basically the same as Host A, but with some differences.&lt;/p&gt;

&lt;p&gt;Firstly, you’ll need to create a new security group for the TunnelHound host because it will need to
be publicly accessible via WireGuard. WireGuard runs on any UDP port, but for this example, we’ll
choose 51821. Also make sure to enable ports 443 and 80, which is required to configure the
TunnelHound appliance. These ports can be left open.&lt;/p&gt;

&lt;p&gt;For instance type, choose &lt;code class=&quot;highlighter-rouge&quot;&gt;t2.micro&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;t2.nano&lt;/code&gt;. In general, your VPN host needs to be
appropriately scaled based on the expected number of concurrent connections, but for most small
networks, a &lt;code class=&quot;highlighter-rouge&quot;&gt;t2.micro&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;t2.nano&lt;/code&gt; instance is appropriate.&lt;/p&gt;

&lt;p&gt;In the &lt;strong&gt;Configure Instance&lt;/strong&gt; tab, choose the VPC and public subnet configured above and again, make
sure to request a public IP.&lt;/p&gt;

&lt;p&gt;In the &lt;strong&gt;Configure Security Group&lt;/strong&gt; tab, enable SSH access via the internal VPC and then enable UDP
access on port 51821 to anywhere. This port is secured via WireGuard, so it is safe to expose
publicly.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/wirehound-host-security-group.png&quot; alt=&quot;The Security group settings for the TunnelHound host&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now, launch the instance. When the confirmation page appears, click on the instance ID as shown
below to be taken to the instance details page.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/instance-id-link-confirmation-page.png&quot; alt=&quot;The instance ID link on the confirmation page&quot; /&gt;&lt;/p&gt;

&lt;p&gt;You will now be taken to a listing table containin your instance. Note the public IP address for
your instance. Once the instance state changes to &lt;strong&gt;Running&lt;/strong&gt;, navigate to &lt;code class=&quot;highlighter-rouge&quot;&gt;https://&amp;lt;your ip
address&amp;gt;&lt;/code&gt;. You may need to wait a few minutes or re-attempt to connect in order to wait for the
appliance to finish booting.&lt;/p&gt;

&lt;p&gt;You’ll likely meet a page now that the certificate authority is invalid. TunnelHound uses a
self-signed certificate to secure communications between clients and the server. This is good enough
for now, but in production, you’ll likely want to set
up &lt;a href=&quot;https://docs.tunnelhound.com/install/ssl&quot;&gt;Let’s Encrypt or a custom certificate&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Accept the ‘invalid’ certificate to begin the TunnelHound setup. You’ll now be taken to the TunnelHound
setup wizard. The first step is to create an administration account. Enter your name, e-mail, and a
password. Then click &lt;strong&gt;Next&lt;/strong&gt; to set up the administrator.&lt;/p&gt;

&lt;p&gt;You can skip the e-mail configuration. This is only necessary for multi-user setups. You can also
skip the license setup. Out of the box, TunnelHound supports up to six devices and three separate
users. You’ll have to &lt;a href=&quot;https://tunnelhound.com/pricing&quot;&gt;pay for more users&lt;/a&gt;
by &lt;a href=&quot;https://docs.tunnelhound.com/admin/licenses&quot;&gt;purchasing a license&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Click through the remaining parts of the wizard, to be taken to the TunnelHound dashboard:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/wirehound-dashboard.png&quot; alt=&quot;The TunnelHound dashboard&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;setting-up-the-endpoint&quot;&gt;Setting up the endpoint&lt;/h2&gt;

&lt;p&gt;To create a VPN, we’ll need to set up an &lt;em&gt;endpoint&lt;/em&gt;. Click the &lt;strong&gt;Admin&lt;/strong&gt; menu, and then the
&lt;strong&gt;Endpoints&lt;/strong&gt; item.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/admin-menu-endpoint-selected.png&quot; alt=&quot;Clicking the endpoints item&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Then, click the &lt;strong&gt;Add Endpoint&lt;/strong&gt; button, and fill in the form as shown below:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/add-endpoint-configuration-howto.png&quot; alt=&quot;The endpoint configuration&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now, navigate back to the TunnelHound dashboard, and click the &lt;strong&gt;Add Device&lt;/strong&gt; button. Fill in the form
as shown below:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/add-device-configuration-howto.png&quot; alt=&quot;The device configuration&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;Add Device&lt;/strong&gt; to set up the device.&lt;/p&gt;

&lt;h2 id=&quot;setting-up-your-device&quot;&gt;Setting up your device&lt;/h2&gt;

&lt;p&gt;You’ll now see a dialog containing instructions on how to set up your device. We’ll be following the
generic Linux instructions. You’ll need to make sure your computer is set up for WireGuard and has
the &lt;code class=&quot;highlighter-rouge&quot;&gt;wg-quick&lt;/code&gt; command installed.&lt;/p&gt;

&lt;p&gt;First, download the configuration file. Then, place it in your home directory, and rename it to
&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;interface&amp;gt;.conf&lt;/code&gt;, where &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;interface&amp;gt;&lt;/code&gt; is the name of the local WireGuard interface you want to
create. Something like &lt;code class=&quot;highlighter-rouge&quot;&gt;wg0.conf&lt;/code&gt; is probably good enough. Then run,&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo wg-quick up wg0.ini
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Congratulations! You’re now connected to the VPN. If you now navigate to the &lt;em&gt;private&lt;/em&gt; IP address of
the TunnelHound instance, you should be able to log in.&lt;/p&gt;

&lt;h2 id=&quot;sshing-into-hosts-a-and-b&quot;&gt;SSHing into Hosts A and B&lt;/h2&gt;

&lt;p&gt;You can now SSH directly into Host A or B using their private ip.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ssh -i &amp;lt;path/to/id.pem&amp;gt; ec2-user@&amp;lt;host.a.or.b.ip&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;For us, Host B, which is contained completely in the private subnet, has IP &lt;code class=&quot;highlighter-rouge&quot;&gt;172.16.0.125&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can similarly, log in to Host A. To confirm that it’s working, try bringing down the interface by running&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo wg-quick down wg0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now, if you try SSHing again, you’ll notice that traffic no longer flows.&lt;/p&gt;

&lt;h1 id=&quot;going-further&quot;&gt;Going further&lt;/h1&gt;

&lt;p&gt;You can now use AWS security groups to configure your hosts – even your public ones – to only
offer certain services on your internal network. Using TunnelHound, you
can &lt;a href=&quot;https://docs.tunnelhound/admin/users&quot;&gt;invite users to join your VPN&lt;/a&gt; and let them manage their
own access. Administrators can delete devices, revoke credentials, and manage access all from one
convenient internal dashboard. Larger deployments can purchase
a &lt;a href=&quot;https://docs.tunnelhound.com/admin/licenses&quot;&gt;TunnelHound license&lt;/a&gt; to increase usage limits and get
priority support.&lt;/p&gt;

&lt;p&gt;That’s it! In a few easy minutes, we were able to set up a simple VPN to protect our private cloud
resources. We used &lt;a href=&quot;https://tunnelhound.com&quot;&gt;TunnelHound&lt;/a&gt; to provide a WireGuard® compatible VPN
and Amazon EC2 and VPC to provide isolated cloud computing resources. For more information, see
the &lt;a href=&quot;https://docs.tunnelhound.com&quot;&gt;TunnelHound documentation&lt;/a&gt;.&lt;/p&gt;</content><author><name>{&quot;name&quot;=&gt;nil, &quot;email&quot;=&gt;nil, &quot;twitter&quot;=&gt;nil}</name></author><summary type="html">These days, many businesses choose to host their entire infrastructure on a cloud provider, like Amazon. This has a number of benefits, such as the ability to quickly scale up or down or reductions in initial capex. One of the difficulties with cloud environments is offering secured access to private cloud resource with VPNs. The native cloud solutions, like Amazon VPN, can be costly. For example, running an Amazon Client VPN costs $0.15/hr and then an additional $0.05/hr for every client connected. For a small company with four employees connected 8 hours every weekday, this can add up to almost 200 / month. If your employees keep their laptops on all day, costs can quickly escalate to several hundreds of dollars a month. That’s not to mention bandwidth costs.</summary></entry><entry><title type="html">Introducing TunnelHound</title><link href="https://tunnelhound.com/tunnelhound/vpn/2020/10/12/introducing-wirehound/" rel="alternate" type="text/html" title="Introducing TunnelHound" /><published>2020-10-12T00:00:00+00:00</published><updated>2020-10-12T00:00:00+00:00</updated><id>https://tunnelhound.com/tunnelhound/vpn/2020/10/12/introducing-wirehound</id><content type="html" xml:base="https://tunnelhound.com/tunnelhound/vpn/2020/10/12/introducing-wirehound/">&lt;p&gt;Setting up a WireGuard® VPN used to involve sorting through endless manual pages, messing around
with error-prone configuration, crossing your fingers, and lots of swearing. But no more!
Introducing TunnelHound, the first commercial provisioning server for WireGuard®. Set up a
WireGuard® VPN in minutes, with support for SAML SSO auto-provisioning, user self-service,
mandatory expirations, diagnostics, etc.&lt;/p&gt;

&lt;h3 id=&quot;what-is-wireguard&quot;&gt;What is WireGuard®?&lt;/h3&gt;

&lt;p&gt;WireGuard® is the easiest to use, secure, maximally awesome VPN solution on the planet. But
don’t just take our word for it. Here’s what Linus Torvalds, the author of the Linux kernel has to
say about it:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Can I just once again state my love for it and hope it gets merged soon? Maybe the code isn’t perfect, but I’ve skimmed it, and compared to the horrors that are OpenVPN and IPSec, it’s a work of art.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;what-is-tunnelhound&quot;&gt;What is TunnelHound?&lt;/h3&gt;

&lt;p&gt;TunnelHound is a commercial provisioning server for WireGuard. That means that it helps you:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Set up a WireGuard cloud VPN&lt;/li&gt;
  &lt;li&gt;Provide secure access to your business network to your employees, contractors, and other agents&lt;/li&gt;
  &lt;li&gt;Allow users to administer their own WireGuard keys and devices&lt;/li&gt;
  &lt;li&gt;Set up Linux IP routing for access control, throttling, and logging&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;why-tunnelhound-v-vanilla-wireguard&quot;&gt;Why TunnelHound v vanilla WireGuard®?&lt;/h3&gt;

&lt;p&gt;TunnelHound offers a number of advantages to using WireGuard directly:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Simplified deployment&lt;/strong&gt; – No need to mess around with configuration files&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;User self-service&lt;/strong&gt; – Let your users administer their own devices. Simplify your IT workload by
letting users perform most common tasks&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Secure peer creation&lt;/strong&gt; – The user self-service portal means that administrators never have to
deal with creating private keys. Your server only ever sees the public key.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Automatic integration&lt;/strong&gt; – TunnelHound lets your organization’s users sign in automatically via
SAML, thus removing the need to manually create users (available in enterprise plans only)&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Polished user experience&lt;/strong&gt; – Your web designer probably doesn’t want to futz around with the
command line. TunnelHound provides a modern, polished user experience with detailed instructions on
how to set up VPN connections on all modern operating systems.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Automatic updates&lt;/strong&gt; – Licensed TunnelHound appliances automatically update with little downtime&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Commercial support&lt;/strong&gt; – All licensed TunnelHound installations come with our &lt;em&gt;Epic&lt;/em&gt;
support! This means we’ll get back to your support inquiry within 24 hours. Enterprise plans come
with phone support, for additional peace of mind.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;how-do-i-get-tunnelhound&quot;&gt;How do I get TunnelHound?&lt;/h3&gt;

&lt;p&gt;You can get TunnelHound on almost any Linux device via &lt;a href=&quot;https://docs.tunnelhound.com/install/docker&quot;&gt;Docker&lt;/a&gt; or
directly on Amazon AWS &lt;a href=&quot;https://docs.tunnelhound.com/install/cloud/aws&quot;&gt;as an AMI&lt;/a&gt;.&lt;/p&gt;</content><author><name>{&quot;name&quot;=&gt;nil, &quot;email&quot;=&gt;nil, &quot;twitter&quot;=&gt;nil}</name></author><summary type="html">Setting up a WireGuard® VPN used to involve sorting through endless manual pages, messing around with error-prone configuration, crossing your fingers, and lots of swearing. But no more! Introducing TunnelHound, the first commercial provisioning server for WireGuard®. Set up a WireGuard® VPN in minutes, with support for SAML SSO auto-provisioning, user self-service, mandatory expirations, diagnostics, etc.</summary></entry></feed>