<?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>static route &#8211; SMsoft &#8211; informatica e dintorni</title>
	<atom:link href="https://blog.smsoft.it/tag/static-route/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.smsoft.it</link>
	<description>consigli settimanali su MacOS, GNU/Linux ed Open Source</description>
	<lastBuildDate>Wed, 03 Mar 2021 11:54:21 +0000</lastBuildDate>
	<language>it-IT</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=89407</generator>
	<item>
		<title>BASH: recuperare l&#8217;IP di un server remoto ed aggiungere una specifica rotta</title>
		<link>https://blog.smsoft.it/2021/03/09/bash-recuperare-lip-di-un-server-remoto-ed-aggiungere-una-specifica-rotta/</link>
					<comments>https://blog.smsoft.it/2021/03/09/bash-recuperare-lip-di-un-server-remoto-ed-aggiungere-una-specifica-rotta/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 09 Mar 2021 09:30:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[dig]]></category>
		<category><![CDATA[route]]></category>
		<category><![CDATA[routing]]></category>
		<category><![CDATA[static route]]></category>
		<guid isPermaLink="false">https://blog.smsoft.it/?p=4892</guid>

					<description><![CDATA[Qualche giorno fa mi è servito creare uno script bash che aggiungesse una nuova rotta statica al cambiamento dell&#8217;IP associato ad un FQDN. Questo uno script bash che recupera l&#8217;IP associato ad un FQDN e se non esiste una rotta statica, la crea: #!/bin/bash GW="192.168.10.4" RTMP=$(dig +short a.rtmp.youtube.com &#124; tail -n1) EXIST=ip route show $RTMP ... <a title="BASH: recuperare l&#8217;IP di un server remoto ed aggiungere una specifica rotta" class="read-more" href="https://blog.smsoft.it/2021/03/09/bash-recuperare-lip-di-un-server-remoto-ed-aggiungere-una-specifica-rotta/" aria-label="Per saperne di più su BASH: recuperare l&#8217;IP di un server remoto ed aggiungere una specifica rotta">Leggi tutto</a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Qualche giorno fa mi è servito creare uno script bash che aggiungesse una nuova rotta statica al cambiamento dell&#8217;IP associato ad un FQDN.</p>



<p class="wp-block-paragraph">Questo uno script bash che recupera l&#8217;IP associato ad un FQDN e se non esiste una rotta statica, la crea:</p>



<pre class="wp-block-preformatted">#!/bin/bash

 GW="192.168.10.4"
 RTMP=$(dig +short a.rtmp.youtube.com | tail -n1)
 EXIST=<code>ip route show $RTMP | wc -l</code>
 if [ $EXIST -eq 0 ]
 then
     echo "$RTMP non esiste, lo agggiungo alla rotta"
     ip route add $RTMP/32 via $GW
 else
    echo "rotta per $RTMP già presente"
 fi</pre>



<p class="wp-block-paragraph">lo script si può puoi aggiungere nel crontab in modo che venga eseguito in automatico di tanto in tanto.</p>



<p class="wp-block-paragraph">Se occorre anche rimuovere la vecchia rotta, si può aggiungere questa parte di codice alla fine dello script:</p>



<pre class="wp-block-preformatted">ACTUAL=$(ip r |grep $GW'| awk '{ print $1 }')
 for i in $ACTUAL ; do
    if [ "$i" != $RTMP  ]; then
      echo "$i non è $RTMP, rimuovo"
      ip route del $i/32 via $GW
   fi
 done</pre>



<p class="wp-block-paragraph">enjoy!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.smsoft.it/2021/03/09/bash-recuperare-lip-di-un-server-remoto-ed-aggiungere-una-specifica-rotta/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
