<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Use &#8211; Hostry Help Center</title>
	<atom:link href="https://help.hostry.com/article-tags/use/feed/" rel="self" type="application/rss+xml" />
	<link>https://help.hostry.com</link>
	<description>Full information on how to use HOSTRY, provided by 24/7 community based support</description>
	<lastBuildDate>Wed, 13 Jan 2021 09:47:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.9.12</generator>

<image>
	<url>https://help.hostry.com/wp-content/uploads/cache/2021/01/cropped-apple-icon-180x180-1/836712163.png</url>
	<title>Use &#8211; Hostry Help Center</title>
	<link>https://help.hostry.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How To Use Ipset on CentOS 7</title>
		<link>https://help.hostry.com/knowledge-base/how-to-use-ipset-on-centos-7/</link>
					<comments>https://help.hostry.com/knowledge-base/how-to-use-ipset-on-centos-7/#comments</comments>
		
		<dc:creator><![CDATA[Paul Harris]]></dc:creator>
		<pubDate>Thu, 03 Oct 2019 08:18:35 +0000</pubDate>
				<guid isPermaLink="false">https://help.hostry.com/?post_type=ht_kb&#038;p=718</guid>

					<description><![CDATA[For packet filtering systems in Linux Iptables, uniform rules are needed that include tens, hundreds and even thousands of IP addresses. For this, there is an ipset extension. To use ipset in the linux CentOS 7 distribution, you need to install the ipset package and ipset-service. It is implied that [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>For packet filtering systems in <a href="https://en.wikipedia.org/wiki/Iptables"><strong>Linux Iptables</strong></a>, uniform rules are needed that include tens, hundreds and even thousands of IP addresses. For this, there is an <strong>ipset</strong> extension. To use ipset in the linux CentOS 7 distribution, you need to install the ipset package and ipset-service.<br> It is implied that the reader of this article is familiar with Linux iptables.</p>



<p><code>[root @ localhost ~] # install ipset-service</code></p>



<p><strong>Ipset-service</strong> ipset auto-loading service for system booting. By default, it is disabled. Turn it on:</p>



<p><code>[root @ localhost ~] # systemctl enable ipset</code></p>



<p>If you have iptables-service installed and you use sets in your rules, then the ipset service must be enabled, otherwise the iptables rules simply won’t load. </p>



<p>To manage lists, there is an <strong>ipset </strong>console<strong> </strong>utility and the iptables extension &#8211; SET. In man pages <strong>iptables-extensions</strong>, search for the keyword &#8216;ipset&#8217; there there is documentation for lists as a filter and for lists as the action <strong>&#8216;-j SET&#8217; </strong>add/remove addresses to the list.</p>



<h2 id="example-1" >Example 1</h2>



<p>Creation of a white list of IP addresses, which are open access to 22 ports (SSH)</p>



<p><code>[root@localhost ~]# ipset create SSH_WL hash:ip</code></p>



<p>We specified the list type <strong>&#8216;hash: ip&#8217; </strong>&#8211; Only <strong>IPv4</strong> IP addresses can be added to this list.<br> If there is a need to add networks (such as<strong> 192.168.0.0/24</strong>) then you will need to declare the type &#8216;<strong>hash: net</strong>&#8216;. List types are defined by the Linux kernel module or can be compiled into the kernel. </p>



<p>To view supported views, you can enter: </p>



<p><code>[root@localhost ~]# ipset --help</code></p>



<p>The lines below:</p>



<p><code>----------------//---------------------<br> Supported set types:<br> --------------//----------------------- </code></p>



<p>There will be a list of all supported list types.</p>



<blockquote class="wp-block-quote is-style-default"><p><code>[root@localhost ~]# ipset add SSH_WL 45.67.89.101</code></p><p><code>[root@localhost ~]# ipset add SSH_WL 12.34.56.78</code></p><p><code>[root@localhost ~]# ipset add SSH_WL 123.4.56.78</code></p><p><code>[root@localhost ~]# ipset add SSH_WL 10.234.56.78</code></p></blockquote>



<p><code>[root@localhost ~]# service ipset save</code></p>



<p><strong>These rules, which are presented below are not recommended to be thoughtlessly copied; their behavior strongly depends on the first 3 rules of the INPUT chain!</strong></p>



<p><code>[root@localhost ~]# iptables -I INPUT 3 -p tcp --dport 22 -m conntrack --ctstate NEW -m set --match-set  SSH_WL src NEW -j ACCEPT</code></p>



<p><code>[root@localhost ~]# iptables -I INPUT 4 -p tcp --dport 22 --ctstate NEW -j DROP</code></p>



<p><code>[root@localhost ~]# service iptables save</code></p>



<p>You can see the list of addresses of all lists:</p>



<p><code>[root@localhost ~]# ipset list<br>  Name: SSH<br> Type: hash:ip<br> Revision: 1<br> Header: family inet hashsize 1024 maxelem 65536<br> Size in memory: 16592<br> References: 1<br> Members:<br> 45.67.89.101<br> 12.34.56.78<br> 123.4.56.78<br> 10.234.56.78</code></p>



<h2 id="example-2" >Example 2</h2>



<p>Creating a dynamic list of addresses trying to connect (or simply scanning) the 23/tcp port (telnet service) with a timeout of 2 hours (7200 seconds).</p>



<p><code>[root@localhost ~]# ipset create telnet_try hash:ip --timeout 72000</code></p>



<p><code>[root@localhost ~]# service ipset save</code></p>



<p><strong>These rules, which are presented below are not recommended to be thoughtlessly copied; their behavior strongly depends on the first 3 rules of the INPUT chain!</strong></p>



<p><code>[root@localhost ~]# iptables -I INPUT 3 -p tcp --dport 23 -m conntrack --ctstate NEW -j SET telnet_try src</code></p>



<p>If you wish, you can use IPTALBES with another timeout, say 16 hours. And you can even make the shell (bash) calculate the number of seconds in 16 hours</p>



<p><code>[root@localhost ~]# iptables -I INPUT 3 -p tcp --dport 23 -m conntrack --ctstate NEW -j SET telnet_try src --timeout $(( 60 * 60 * 16 ))</code></p>



<p><strong>Save this rules</strong></p>



<p><code>[root@localhost ~]# service iptables save</code></p>



<p>After some time (hour, day, week), you can see from which IPs in the last 2 there were interesting packets to the insecure telnet service</p>



<p><code>[root@localhost ~]# ipset list telnet_try<br> Name: telnet_try<br> Type: hash:ip<br> Revision: 1<br> Header: family inet hashsize 1024 maxelem 65536 timeout 72000<br> Size in memory: 16592<br> References: 1<br> Members:<br> 1.2.3.4 timeout 45879 <br> 5.6.7.8 timeout 71327</code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://help.hostry.com/knowledge-base/how-to-use-ipset-on-centos-7/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
		<item>
		<title>How To Use The Dirname Command on Linux Bash scripts</title>
		<link>https://help.hostry.com/knowledge-base/how-to-use-the-dirname-command-on-linux-bash-scripts/</link>
					<comments>https://help.hostry.com/knowledge-base/how-to-use-the-dirname-command-on-linux-bash-scripts/#comments</comments>
		
		<dc:creator><![CDATA[Alex]]></dc:creator>
		<pubDate>Wed, 10 Jun 2020 07:23:31 +0000</pubDate>
				<guid isPermaLink="false">https://help.hostry.com/?post_type=ht_kb&#038;p=1761</guid>

					<description><![CDATA[The dirname command on Linux prints the path to the file with the last component removed. This basically gives you the directory path from the file path. The dirname command complements the basename command. The basename command retrieves the file name from the path, while dirname retrieves the directory path. [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>The <strong><em>dirname</em></strong> command on Linux prints the path to the file with the last component removed. This basically gives you the directory path from the file path. The dirname command complements the basename command. The basename command retrieves the file name from the path, while dirname retrieves the directory path.</p>



<h2 id="dirname-command-examples" >Dirname Command Examples</h2>



<p>Dirname command has very simple syntax</p>



<pre class="wp-block-preformatted">dirname OPTION PATH</pre>



<p>Using the command will give the directory path:</p>



<pre class="wp-block-preformatted">dirname /home/user/data/filename.txt
/home/user/data</pre>



<p>Like the basename command, the dirname command is actually primitive. It really does not recognize the file path. It just searches for slashes (/) and prints everything that is before the last slash. In fact, you can ask him any line with / in it, and it will work with it. For example: a random string without a file name is very often used. It is possible to see that it still works the same way and displays a line, deleting the last / and the text after it</p>



<pre class="wp-block-preformatted">destroyer@hostry: ~$ dirname dir1/dir2/dir3/dir4
dir1/dir2/dir3
destroyer@hostry: ~$</pre>



<p>If there is no forward slash <strong>(/) </strong>in the path, a period <strong>(.)</strong> Will be displayed, indicating the current directory</p>



<pre class="wp-block-preformatted">destroyer@hostry: ~$ dirname hostry.txt
.
destroyer@hostry: ~$</pre>



<p>You can also use dirname with several paths. It will return the output for each path in a new line:</p>



<pre class="wp-block-preformatted">destroyer@histry: ~$ dirname dir1/file dir2/file
dir1
dir2
destroyer@hostry: ~$</pre>



<p>You can use the <strong>-z</strong> option to get the result on the same line as the output, separated by a NULL character.</p>



<h2 id="using-dirname-in-a-bash-script" >Using Dirname in a <strong>B</strong>ash Script </h2>



<p>Some examples of using the dirname command have been shown. Now, for example, the following will be taken: you have a file path variable and you need to get the path to the directory where this file is located. It could be a very simple script</p>



<pre class="wp-block-preformatted">pathname="/home/dir/data/filename"
result=$(dirname "$pathname")
echo $result</pre>



<p>As mentioned earlier, the dirname command is complemented by the basename command. Unlike dirname, the basename command prints only the last component of the path.</p>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://help.hostry.com/knowledge-base/how-to-use-the-dirname-command-on-linux-bash-scripts/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
