<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dr-QTDS</title>
    <description>The latest articles on DEV Community by Dr-QTDS (@qtds).</description>
    <link>https://dev.to/qtds</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1096846%2Fab1a2f7d-b3a5-436b-8e1e-15e32b0537c6.jpeg</url>
      <title>DEV Community: Dr-QTDS</title>
      <link>https://dev.to/qtds</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/qtds"/>
    <language>en</language>
    <item>
      <title>How to deny access to a server from the public network?</title>
      <dc:creator>Dr-QTDS</dc:creator>
      <pubDate>Wed, 07 Jun 2023 01:37:48 +0000</pubDate>
      <link>https://dev.to/qtds/how-to-deny-access-to-a-server-from-the-public-network-1ob4</link>
      <guid>https://dev.to/qtds/how-to-deny-access-to-a-server-from-the-public-network-1ob4</guid>
      <description>&lt;p&gt;Hello everyone,&lt;/p&gt;

&lt;p&gt;I have a CentOS7 server with a public IP address, but I found every day there are many SSH attacks targeted at it. In the future, I also want to deploy some services on the server. But I am a new hand in Linux, to protect my server I searched the Internet, and found using VPN to connect the server is a secure way to avoid attacks.&lt;/p&gt;

&lt;p&gt;I chose the tailscale as a VPN provider. Now I want to achieve the following objectives:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. All services provided by the server including SSH must be accessed through the VPN.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Tailscale can funcion properly on the server after setting iptables.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After intalling tailscale, the filter table of my service is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[root@hecs-9277 ~]# iptables -nvL
Chain INPUT (policy ACCEPT 109K packets, 11M bytes)
 pkts bytes target     prot opt in     out     source               destination
 249K   25M ts-input   all  --  *      *       0.0.0.0/0            0.0.0.0/0

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ts-forward  all  --  *      *       0.0.0.0/0            0.0.0.0/0

Chain OUTPUT (policy ACCEPT 161K packets, 23M bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain ts-forward (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 MARK       all  --  tailscale0 *       0.0.0.0/0            0.0.0.0/0            MARK xset 0x40000/0xff0000
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            mark match 0x40000/0xff0000
    0     0 DROP       all  --  *      tailscale0  100.64.0.0/10        0.0.0.0/0
    0     0 ACCEPT     all  --  *      tailscale0  0.0.0.0/0            0.0.0.0/0

Chain ts-input (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     all  --  lo     *       100.81.244.76        0.0.0.0/0
    0     0 RETURN     all  --  !tailscale0 *       100.115.92.0/23      0.0.0.0/0
 9239 1268K DROP       all  --  !tailscale0 *       100.64.0.0/10        0.0.0.0/0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As I mentioned, I am a new-hand, I run the following command just want to achieve the goal. But after that, I can't SSH to the sevice. &lt;code&gt;sudo iptables -t filter -I INPUT ! -s 100.64.0.0/10 -j DROP&lt;/code&gt;. Luckily, I can access the server physically, so I delete the rule I have set.&lt;/p&gt;

&lt;p&gt;Now, could anyone teach me how to achieve the goal by setting iptables or something else, please?&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;

</description>
      <category>iptables</category>
      <category>linux</category>
      <category>vpn</category>
      <category>networksecurity</category>
    </item>
  </channel>
</rss>
