<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>iptables — LowEndSpirit</title>
        <link>https://staging.lowendspirit.com/index.php?p=/</link>
        <pubDate>Mon, 06 Apr 2026 13:04:20 +0000</pubDate>
        <language>en</language>
            <description>iptables — LowEndSpirit</description>
    <atom:link href="https://staging.lowendspirit.com/index.php?p=/discussions/tagged/iptables/feed.rss" rel="self" type="application/rss+xml"/>
    <item>
        <title>iptables rules for WireGuard VPN on NAT OpenVZ VPS running Debian 10?</title>
        <link>https://staging.lowendspirit.com/index.php?p=/discussion/2379/iptables-rules-for-wireguard-vpn-on-nat-openvz-vps-running-debian-10</link>
        <pubDate>Wed, 06 Jan 2021 08:53:23 +0000</pubDate>
        <category>Help</category>
        <dc:creator>Freek</dc:creator>
        <guid isPermaLink="false">2379@/index.php?p=/discussions</guid>
        <description><![CDATA[<p>I'm trying to setup WireGuard VPN (TunSafe for that matter) on my NAT OpenVZ VPS running Debian 10. I have an ansible playbook I created to set it up on 'regular' KVM VPSes that I used. The issue I have is with the iptables rules that are needed to route/forward the traffic between the client and the server properly; they don't seem to work.</p>

<p>On my KVM VPSes, I'm using the iptables rule <code>iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE</code><br />
which would translate to <code>iptables -t nat -A POSTROUTING -o venet0 -j MASQUERADE</code> for OpenVZ I figured. However, iptables on my OpenVZ NAT VPS complains 'Chain 'MASQUERADE' does not exist'.</p>

<p>I already switched to the legacy version of iptables instead of nf using <code>update-alternatives –config iptables</code> but the error remains. And indeed, if I run <code>iptables -L</code> I see only three chains: INPUT, FORWARD and OUTPUT...</p>

<p>In the meantime I found this set of iptables rules that makes the VPN connection work:</p>

<pre><code>#Forwarding
iptables -A FORWARD -i venet0 -o tun0 -j ACCEPT
iptables -A FORWARD -i tun0 -o venet0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
#Hardening?
iptables -A INPUT -i tun0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -i tun0 -j DROP
</code></pre>

<p>However, apart from being 5 rules instead of just 1 simple rule, I'm not sure if the rules above are too permissive.</p>

<p>Since I'm no iptables hero myself,  I was hoping someone could help me out here in figuring out the correct set of iptables rules to get WireGuard running on my NAT VPS.</p>

<p>Thanks! <img src="https://staging.lowendspirit.com/plugins/emojiextender/emoji/twitter/smile.png" title=":)" alt=":)" height="18" /></p>
]]>
        </description>
    </item>
    <item>
        <title>Enable IPv4 Access in EUserv IPv6-only VS2-free</title>
        <link>https://staging.lowendspirit.com/index.php?p=/discussion/2293/enable-ipv4-access-in-euserv-ipv6-only-vs2-free</link>
        <pubDate>Sun, 20 Dec 2020 17:20:37 +0000</pubDate>
        <category>Technical</category>
        <dc:creator>yoursunny</dc:creator>
        <guid isPermaLink="false">2293@/index.php?p=/discussions</guid>
        <description><![CDATA[<blockquote><div>
  <p>This post is originally published on yoursunny.com blog <a href="https://yoursunny.com/t/2020/EUserv-IPv4/" rel="nofollow">https://yoursunny.com/t/2020/EUserv-IPv4/</a></p>
</div></blockquote>

<p>EUserv is a virtual private server (VPS) provider in Germany.<br />
Notably, they offer a container-based Linux server, <a rel="nofollow" href="https://www.euserv.com/en/virtual-private-server/root-vserver/v2/vs2-free.php">VS2-free</a>, free of charge.<br />
VS2-free comes with one 1GHz CPU core, 1GB memory, and 10GB storage.<br />
Although I already have more than enough servers to play with, who doesn't like some more computing resources for free?</p>

<p>There's one catch: the VS2-free is IPv6-only.<br />
It neither has a public IPv4 address, nor offers NAT-based IPv4 access.<br />
All you can have is a single /128 IPv6 address.</p>

<pre><code>$ ip addr
1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
546: eth0@if547: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether b2:77:4b:c0:eb:0b brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 2001:db8:6:1::6dae/128 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::5ed4:d66f:bd01:6936/64 scope link
       valid_lft forever preferred_lft forever
</code></pre>

<p>If I attempt to access an IPv4-only destination, a "Network is unreachable" error appears:</p>

<pre><code>$ host lgger.nexusbytes.com
lgger.nexusbytes.com has address 46.4.199.225
$ ping -n -c 4 lgger.nexusbytes.com
connect: Network is unreachable
</code></pre>

<p>Not having IPv4 access severely restricts the usefulness of the VS2-free, because I would be unable to access many external resources that are not yet IPv6-enabled.<br />
Is there a way to get <em>some</em> IPv4 access in the IPv6-only VS2-free vServer?</p>

<h2>NAT64</h2>

<p><a rel="nofollow" href="https://tools.ietf.org/html/rfc6146">Stateful NAT64 translation</a> is a network protocol that allows IPv6-only clients to contact IPv4 servers using unicast UDP, TCP, or ICMP.<br />
It relies on a dual-stack server, known as a <strong>NAT64 translator</strong>, to proxy packets between IPv6 and IPv4 networks.</p>

<p>There are a number of <a rel="nofollow" href="https://nat64.xyz/">public NAT64 services</a> in Europe that would enable IPv4 access from my server.<br />
To use NAT64, all I need to do is changing the DNS settings in my server:</p>

<pre><code>$ sudoedit /etc/resolvconf/resolv.conf.d/base
    nameserver 2a01:4f9:c010:3f02::1
    nameserver 2a00:1098:2c::1
    nameserver 2a00:1098:2b::1

$ sudo resolvconf -u
</code></pre>

<p>Note that on a Debian 10 system with <code>resolveconf</code> package, the proper way to change DNS servers is editing <code>/etc/resolvconf/resolv.conf.d/base</code> and then executing <code>resolvconf -u</code> to regenerate <code>/etc/resolv.conf</code>.<br />
If you modify <code>/etc/resolv.conf</code> directly, the changes will be overwritten during the next reboot.</p>

<p>After making the changing, DNS responses for IPv4-only destinations would contain additional IPv6 addresses that belong to the NAT64 translator, which would facilitate the connection:</p>

<pre><code>$ host lgger.nexusbytes.com
lgger.nexusbytes.com has address 46.4.199.225
lgger.nexusbytes.com has IPv6 address 2a00:1098:2c::1:2e04:c7e1
lgger.nexusbytes.com has IPv6 address 2a01:4f9:c010:3f02:64:0:2e04:c7e1
lgger.nexusbytes.com has IPv6 address 2a00:1098:2b::2e04:c7e1

$ ping -n -c 4 lgger.nexusbytes.com
PING lgger.nexusbytes.com(2a00:1098:2c::1:2e04:c7e1) 56 data bytes
64 bytes from 2a00:1098:2c::1:2e04:c7e1: icmp_seq=1 ttl=41 time=39.9 ms
64 bytes from 2a00:1098:2c::1:2e04:c7e1: icmp_seq=2 ttl=41 time=39.7 ms
64 bytes from 2a00:1098:2c::1:2e04:c7e1: icmp_seq=3 ttl=41 time=39.6 ms
64 bytes from 2a00:1098:2c::1:2e04:c7e1: icmp_seq=4 ttl=41 time=39.8 ms
</code></pre>

<p>It is easy to gain IPv4 access on the EUserv VS2-free container by using a public NAT64 service, but there are several drawbacks:</p>

<ul>
<li><p>The IPv4 addresses of public NAT64 services are shared by many users.<br />
If any other user misbehaves, the shared IPv4 address of the NAT64 translator could be blocklisted by the destination IPv4 service.</p></li>
<li><p>The NAT64 translator could apply rate limits if it gets busy.</p></li>
<li><p>While we can contact an IPv4-only destination by its hostname, it is still not possible to contact an IPv4 address:</p>

<pre><code>$ ping 8.8.8.8
connect: Network is unreachable
</code></pre></li>
</ul>

<h2>IPv4 NAT over VXLAN</h2>

<p>To get true IPv4 access on an IPv6-only server, we need to create a tunnel between the IPv6-only server and a dual-stack server, and then configure Network Address Translation (NAT) on the dual stack server.<br />
Many people would think about using a VPN software, such as OpenVPN or WireGuard.<br />
However, VPN is overkill, because there is a lighter weight solution: VXLAN.</p>

<p><a rel="nofollow" href="https://tools.ietf.org/html/rfc7348">VXLAN</a>, or Virtual eXtensible Local Area Network, is a framework for overlaying virtualized layer 2 networks over layer 3 networks.<br />
In our case, I can create a virtualized Ethernet (layer 2) network over an IPv6 (layer 3) network.<br />
Then, I can assign IPv4 addresses to the virtual Ethernet adapters, in order to give IPv4 access to the previously IPv6-only VS2-free vServer.</p>

<p>I have a small dual-stack server in Germany, offered by <a rel="nofollow" href="https://hosting.gullo.me/">Gullo's Hosting</a>.<br />
It is an OpenVZ 7 container.<br />
It runs Debian 10, the same operating system as my VS2-free.<br />
I will be using this server to share IPv4 to the VS2-free.</p>

<p>In the examples below:</p>

<ul>
<li><code>2001:db8:473a:723d:276e::2</code> is the public IPv6 address of the dual-stack server.</li>
<li><code>2001:db8:6:1::6dae</code> is the public IPv6 address of the IPv6-only server.</li>
<li><code>192.0.2.1</code> is the public IPv4 address of the dual-stack server.</li>
</ul>

<p>After reverting the DNS changes from the previous section, I execute the following commands on the EUserv vServer to setup a VXLAN tunnel:</p>

<pre><code>sudo ip link add vx84 type vxlan id 0 remote 2001:db8:473a:723d:276e::2 local 2001:db8:6:1::6dae dstport 4789
sudo ip link set vx84 mtu 1420
sudo ip link set vx84 up
sudo ip addr add 192.168.84.2/24 dev vx84
sudo ip route add 0.0.0.0/0 via 192.168.84.1
</code></pre>

<p>Note that I reduced the MTU of the VXLAN tunnel interface to 1420 from the default 1500.<br />
This is necessary to accommodate the overhead of VXLAN headers, so that the encapsulated IPv6 packets can fit into the normal MTU.</p>

<p>On the dual-stack server, I execute these commands to setup its end of the tunnel and enable NAT:</p>

<pre><code>sudo ip link add vx84 type vxlan id 0 remote 2001:db8:6:1::6dae local 2001:db8:473a:723d:276e::2 dstport 4789
sudo ip link set vx84 mtu 1420
sudo ip link set vx84 up
sudo ip addr add 192.168.84.1/24 dev vx84
sudo iptables-legacy -t nat -A POSTROUTING -s 192.168.84.0/24 ! -d 192.168.84.0/24 -j SNAT --to 192.0.2.1
</code></pre>

<p>It's worth noting that the command for enabling NAT is <em>iptables-legacy</em> instead of <em>iptables</em>.<br />
Apparently, there are <a rel="nofollow" href="https://developers.redhat.com/blog/2020/08/18/iptables-the-two-variants-and-their-relationship-with-nftables/">two variants of iptables</a> that access different kernel APIs.<br />
Although both commands would succeed, only <em>iptables-legacy</em> is effective in an OpenVZ 7 container.<br />
This had me scratching my head for a while.</p>

<p>After these setup, I'm able to access IPv4 from the IPv6-only server:</p>

<pre><code>$ traceroute -n -q1 lgger.nexusbytes.com
traceroute to lgger.nexusbytes.com (46.4.199.225), 30 hops max, 60 byte packets
 1  192.168.84.1  23.566 ms
 2  *
 3  213.239.229.89  34.058 ms
 4  213.239.229.130  23.615 ms
 5  94.130.138.54  24.077 ms
 6  46.4.199.225  23.955 ms
</code></pre>

<p>In Wireshark, these packets would look like this:</p>

<pre><code>Frame 5: 146 bytes on wire (1168 bits), 146 bytes captured (1168 bits)
Linux cooked capture v1
Internet Protocol Version 6, Src: 2001:db8:6:1::6dae, Dst: 2001:db8:473a:723d:276e::2
User Datagram Protocol, Src Port: 53037, Dst Port: 4789
Virtual eXtensible Local Area Network
Ethernet II, Src: b6:ab:7c:af:51:d1 (b6:ab:7c:af:51:d1), Dst: be:ce:c9:cf:a7:f3 (be:ce:c9:cf:a7:f3)
Internet Protocol Version 4, Src: 192.168.84.2, Dst: 46.4.199.225
User Datagram Protocol, Src Port: 50047, Dst Port: 33439
Data (32 bytes)
</code></pre>

<h2>Make Them Persistent</h2>

<p>Effect of <code>ip</code> commands will be lost after a reboot.<br />
Normally the VXLAN tunnel should be written into the <em>ifupdown</em> configuration file, but as I <a rel="nofollow" href="https://yoursunny.com/t/2020/preferred-lft-vz7/">discovered earlier</a>, OpenVZ 7 would revert any modifications to the <code>/etc/network/interfaces</code> file.<br />
Thus, I have to apply these changes dynamically using a systemd service.</p>

<p>The systemd service unit for the IPv6-only server is:</p>

<pre><code>[Unit]
Description=VXLAN tunnel to vps9
After=network-online.target
Wants=network-online.target

[Service]
ExecStartPre=ip link add vx84 type vxlan id 0 remote 2001:db8:473a:723d:276e::2 local 2001:db8:6:1::6dae dstport 4789
ExecStartPre=ip link set vx84 mtu 1420
ExecStartPre=ip link set vx84 up
ExecStartPre=ip addr add 192.168.84.2/24 dev vx84
ExecStartPre=ip route add 0.0.0.0/0 via 192.168.84.1
ExecStart=true
RemainAfterExit=yes
ExecStopPost=ip link del vx84

[Install]
WantedBy=multi-user.target
</code></pre>

<p>The systemd service unit for the dual-stack server is:</p>

<pre><code>[Unit]
Description=VXLAN tunnel to vps2
After=network-online.target
Wants=network-online.target

[Service]
ExecStartPre=ip link add vx84 type vxlan id 0 remote 2001:db8:6:1::6dae local 2001:db8:473a:723d:276e::2 dstport 4789
ExecStartPre=ip link set vx84 mtu 1420
ExecStartPre=ip link set vx84 up
ExecStartPre=ip addr add 192.168.84.1/24 dev vx84
ExecStartPre=iptables-legacy -t nat -A POSTROUTING -s 192.168.84.0/24 ! -d 192.168.84.0/24 -j SNAT --to 192.0.2.1
ExecStart=true
RemainAfterExit=yes
ExecStopPost=iptables-legacy -t nat -D POSTROUTING -s 192.168.84.0/24 ! -d 192.168.84.0/24 -j SNAT --to 192.0.2.1
ExecStopPost=ip link del vx84

[Install]
WantedBy=multi-user.target
</code></pre>

<p>On both servers, this service unit file should be uploaded to <code>/etc/systemd/system/vx84.service</code>.<br />
Then, I can enable the service unit with these commands:</p>

<pre><code>sudo systemctl daemon-reload
sudo systemctl enable vx84
</code></pre>

<p>They will take effect after a reboot:</p>

<pre><code>$ ip addr show vx84
4: vx84: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether f2:4c:5d:6c:4b:25 brd ff:ff:ff:ff:ff:ff
    inet 192.168.84.2/24 scope global vx84
       valid_lft forever preferred_lft forever
    inet6 fe80::f04c:5dff:fe6c:4b25/64 scope link
       valid_lft forever preferred_lft forever

$ ping -c 4 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1: icmp_seq=1 ttl=57 time=28.9 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=57 time=28.7 ms
64 bytes from 1.1.1.1: icmp_seq=3 ttl=57 time=28.9 ms
64 bytes from 1.1.1.1: icmp_seq=4 ttl=57 time=28.10 ms
</code></pre>

<h2>Conclusion</h2>

<p>This article describes two methods of gaining IPv4 access on an IPv6-only server such as the EUserv VS2-free.</p>

<ul>
<li>Use a public NAT64 translator.</li>
<li>Establish a VXLAN tunnel to a dual-stack server, and then configure IPv4 addresses and NAT on the virtual Ethernet interfaces.</li>
</ul>

<p>To workaround OpenVZ 7 limitation of not being able to modify <code>/etc/network/interfaces</code>, we use a systemd service unit to dynamically establish and teardown the VXLAN tunnel and related configuration.</p>
]]>
        </description>
    </item>
    <item>
        <title>inceptionhosting does not work iptables</title>
        <link>https://staging.lowendspirit.com/index.php?p=/discussion/458/inceptionhosting-does-not-work-iptables</link>
        <pubDate>Tue, 07 Jan 2020 17:09:36 +0000</pubDate>
        <category>Technical</category>
        <dc:creator>Andr_C</dc:creator>
        <guid isPermaLink="false">458@/index.php?p=/discussions</guid>
        <description><![CDATA[<p>I use vps as a proxy. in the iptables settings is blocking some sites. before the openVZ update, everything worked well on the old version. but it’s not working now.</p>

<p>I am using this command:<br />
<strong>iptables -A OUTPUT -m string --string "vk.com" --algo kmp --to 65535 -p all -j REJECT</strong></p>

<p>everything worked on the old version but now displays an error message:<br />
<strong>iptables: No chain/target/match by that name.</strong></p>

<p>How to fix it?</p>

<hr />

<p>My Node: Mininode1b  (NETHERLANDS)<br />
My IP: 192.168.1.101</p>
]]>
        </description>
    </item>
   </channel>
</rss>
