<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[MischievousBOSS - Medium]]></title>
        <description><![CDATA[科技、網路與技術文章的一個集散地，集結各種科技產品的使用經驗 - Medium]]></description>
        <link>https://medium.com/mischievousboss?source=rss----c874955c26c7---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>MischievousBOSS - Medium</title>
            <link>https://medium.com/mischievousboss?source=rss----c874955c26c7---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 06:47:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/mischievousboss" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[MediaWiKi Installation]]></title>
            <link>https://medium.com/mischievousboss/mediawiki-installation-a6ce37566e0e?source=rss----c874955c26c7---4</link>
            <guid isPermaLink="false">https://medium.com/p/a6ce37566e0e</guid>
            <category><![CDATA[synology]]></category>
            <category><![CDATA[nas]]></category>
            <category><![CDATA[wikimedia]]></category>
            <dc:creator><![CDATA[Mason Lyu]]></dc:creator>
            <pubDate>Sun, 25 Apr 2021 13:14:19 GMT</pubDate>
            <atom:updated>2021-04-25T13:14:19.611Z</atom:updated>
            <content:encoded><![CDATA[<p>This article describe the manual installation of MediaWiKi on Synology DSM. Of course, we can install MediaWiKi within <em>Package Center</em>, but what if we want to have two or more MediaWiKi sites on single Synology DiskStation?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*owEa__svOJFPyu-o" /><figcaption>Photo by <a href="https://unsplash.com/@kumakum?utm_source=medium&amp;utm_medium=referral">Kuma Kum</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Prerequisite</h3><p>MediaWiki requires PHP, database and web server to be installed on system. Check out <a href="https://www.mediawiki.org/wiki/Compatibility">MediaWiKi Compatibility</a> to find out the eligible software version.</p><h4><strong>PHP</strong></h4><p>The latest stable branch of MediaWiki (1.35) runs on any version of PHP 7.3 from 7.3.19 and higher, and any version of PHP 7.4 from 7.4.3 and higher.Before installing MediaWiKi, some of the PHP extensions are suggested to be enabled additionally.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fsheetsu.com%2Ftables%2Fc4760c60b7&amp;dntp=1&amp;display_name=Sheetsu&amp;url=https%3A%2F%2Fsheetsu.com%2Ftables%2Fc4760c60b7&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=sheetsu" width="700" height="205" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf9c6504530cfd1028d3e2a0ecb368d0/href">https://medium.com/media/cf9c6504530cfd1028d3e2a0ecb368d0/href</a></iframe><h4><strong>Database</strong></h4><p>MediaWiki is compatible with a variety of database servers. Using MySQL or MariaDB is recommended. Since <a href="https://www.mediawiki.org/wiki/MediaWiki_1.34">MediaWiki 1.34</a>, using Oracle and Microsoft SQL Server are no longer supported.</p><h4>Web server</h4><p>MediaWiki is broadly compatible with all major web servers that can invoke a compatible version of PHP. Apache is the most used and tested. Nginx is a good choice as well.</p><h3>Installation</h3><p>1. Download the source file from <a href="https://www.mediawiki.org/wiki/Download">MediaWiKi</a> website.</p><p>2. Follow the <a href="https://www.mediawiki.org/wiki/Manual:Installation_guide==Manual_installation">instruction</a> to install MediaWiKi on system.</p><p>3. Download and modify the content of LocalSettings.php.</p><p>4. Upload LocalSettings.php to the base directory of the MediaWiki installation.</p><p>5. All the changes in LocalSettings.php will be effective immediately without rebooting system.</p><h3>LocalSetting.php</h3><h4>Email Configuration</h4><p>Reference: <a href="https://www.mediawiki.org/wiki/Manual:$wgSMTP">Manual:$wgSMTP</a></p><p>IDHost is a MediaWiki-specific setting used to build the Message-ID email header. If not provided, will default to $wgServer.</p><pre>$wgSMTP = [<br>    &#39;host&#39; =&gt; &#39;ssl://smtp.gmail.com&#39;, // outbox server of the email account<br>    &#39;IDHost&#39; =&gt; &#39;gmail.com&#39;,<br>    &#39;port&#39; =&gt; 465,<br>    &#39;username&#39; =&gt; &#39;myemail@gmail.com&#39;,<br>    &#39;password&#39; =&gt; &#39;********&#39;, // Application password <br>    &#39;auth&#39; =&gt; true<br>];</pre><h4>Group Permissions</h4><ul><li>Check if anonymous user can create an account</li></ul><pre>$wgGroupPermissions[&#39;*&#39;][&#39;createaccount&#39;] = flase;</pre><ul><li>Check if anonymous user can edit the page</li></ul><pre>$wgGroupPermissions[&#39;*&#39;][&#39;edit&#39;] = false;</pre><ul><li>Check if anonymous user can read the page</li></ul><pre>$wgGroupPermissions[&#39;*&#39;][&#39;read&#39;] = false;</pre><ul><li>Add following lines when using VisualEditor since VisualEditor accesses your pages as an anonymous user. <a href="https://www.mediawiki.org/wiki/Topic:Vv35plp6g16qno0s">Reference</a>.</li></ul><pre>if ( $_SERVER[&#39;REMOTE_ADDR&#39;] == &#39;YOUR_SERVER_IP&#39; ) {<br>  $wgGroupPermissions[&#39;*&#39;][&#39;read&#39;] = true;<br>  $wgGroupPermissions[&#39;*&#39;][&#39;edit&#39;] = true;<br>}</pre><h4>Miscellaneous Settings</h4><ul><li>MultimediaViewer extension</li></ul><pre>wfLoadExtension( &#39;MultimediaViewer&#39; );<br>$wgDefaultUserOptions[&#39;multimediaviewer-enable&#39;] = 1;</pre><ul><li>Accepted file extension for uploading</li></ul><pre>$wgFileExtensions = [ &#39;png&#39;, &#39;jpg&#39;, &#39;jpeg&#39;, &#39;tiff&#39;, &#39;ogg&#39;, &#39;mp3&#39;, &#39;doc&#39;, &#39;xls&#39;, &#39;ppt&#39;, &#39;docx&#39;, &#39;xlsx&#39;, &#39;pptx&#39;, &#39;sxc&#39;, &#39;pdf&#39; ];</pre><p><strong><em>The ownership of folder used for uploading needs correct permissions.</em></strong></p><pre>sudo chown –R http:http images/<br>sudo chmod –R 755 images/</pre><h3>Composer</h3><p>Composer is a dependency manager for PHP. Some MediaWiKi extensions will require <a href="https://getcomposer.org/">Composer</a> for installation.</p><h4>Composer Installation</h4><p>1. <em>Composer Merge Plugin</em> requires Composer 1.1.0 or newer, but doesn’t currently support Composer 2.0.</p><p>2. Download composer-setup.php in the base directory of the PHP installation, e.g., /usr/local/etc/php74</p><pre>sudo /usr/local/bin/php74 -r &quot;copy(&#39;https://getcomposer.org/installer&#39;, &#39;composer-setup.php&#39;);&quot;</pre><p>3. Run the setup script to download composer.phar with version 1.10.20.</p><pre>sudo /usr/local/bin/php74 composer-setup.php --version=1.10.20</pre><h3>Itsy Package Management System</h3><p>1. Follow the instructions to install <strong>ipkg</strong> on Synology.</p><pre>cd /tmp</pre><pre>wget <a href="http://ipkg.nslu2-linux.org/feeds/optware/syno-i686/cross/unstable/syno-i686-bootstrap_1.2-7_i686.xsh">http://ipkg.nslu2-linux.org/feeds/optware/syno-i686/cross/unstable/syno-i686-bootstrap_1.2-7_i686.xsh</a></pre><pre>chmod +x syno-i686-bootstrap_1.2-7_i686.xsh</pre><pre>sh syno-i686-bootstrap_1.2-7_i686.xsh</pre><pre>ipkg update</pre><p>2. Install <em>Ghostscript</em> and <em>Xpdf</em> packages</p><pre>ipkg install ghostscript<br>ipkg install xpdf</pre><h3>MediaWiKi Extension</h3><h3>Math</h3><p>1. Download <a href="https://www.mediawiki.org/wiki/Special:ExtensionDistributor?extdistname=Math&amp;extdistversion=REL1_35">Math extension</a> and extract the file(s) by tar in a directory called Math in the extensions/ folder.</p><p>2. Add following code at the bottom of LocalSettings.php.</p><pre>wfLoadExtension( &#39;Math&#39; );</pre><p>3. Run the update script from the base directory of the MediaWiKi installation</p><pre>/usr/local/bin/php74 maintenance/update.php</pre><h3>MSCalendar</h3><p>1. Download <a href="https://www.mediawiki.org/wiki/Special:ExtensionDistributor?extdistname=MsCalendar&amp;extdistversion=REL1_35">MsCalendar extension</a> and extract the file(s) by tar in a directory called MsCalendar in the extensions/folder.</p><p>2. Add following code at the bottom of LocalSettings.php.</p><pre>wfLoadExtension( &#39;Math&#39; );</pre><p>3. Run the update script from the base directory of the MediaWiKi installation</p><pre>/usr/local/bin/php74 maintenance/update.php</pre><h3>Mermaid and Semantic MediaWiki (SMW)</h3><p>1. Add a new file named composer.local.json in the base directory of the MediaWiKi installation.</p><p>2. Modify the content as shown below.</p><pre>{<br>  &quot;require&quot;: {<br>    &quot;mediawiki/semantic-media-wiki&quot;: &quot;~3.2.2&quot;,<br>    &quot;mediawiki/mermaid&quot;: &quot;~3.0&quot;`<br>  }<br>}</pre><p>3. Run the update script from the base directory of the MediaWiKi installation</p><pre>/usr/local/bin/php74 /usr/local/etc/php70/composer.phar update --no-dev</pre><p>4. Add following code at the bottom of LocalSettings.php.</p><pre>wfLoadExtension( &#39;Mermaid&#39; );<br>enableSemantics( &#39;https://example.org/mediawiki&#39; );</pre><p>5. Run the update script from the base directory of the MediaWiKi installation</p><pre>/usr/local/bin/php74 maintenance/update.php</pre><p>6. Check the <em>Special:Version</em> page on your wiki and verify that the extension has been successfully updated.</p><h3>PdfHandler</h3><h4>Prerequisites</h4><p>This extension requires the following packages to be installed first:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fsheetsu.com%2Ftables%2F5137254296&amp;dntp=1&amp;display_name=Sheetsu&amp;url=https%3A%2F%2Fsheetsu.com%2Ftables%2F5137254296&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=sheetsu" width="700" height="262" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c79dead667f960759a9f9c04999abed/href">https://medium.com/media/2c79dead667f960759a9f9c04999abed/href</a></iframe><p>Type which gs convert pdfinfo pdftotext command in your shell to see if you have the above installed first</p><h4><strong>Installation</strong></h4><p>1. Download <a href="https://www.mediawiki.org/wiki/Special:ExtensionDistributor?extdistname=PdfHandler&amp;extdistversion=REL1_35">PdfHandler extension</a> and extract the file(s) by tar in a directory called PdfHandler in the extensions/folder.</p><p>2. Add following code in LocalSettings.php after installing <em>Ghostscript</em> and <em>Xpdf</em> by <strong>ipkg</strong>.</p><pre>$wgMaxShellMemory = 1024000;<br>$wgPdfProcessor = &#39;/opt/bin/gs&#39;;<br>$wgPdfPostProcessor = $wgImageMagickConvertCommand;;<br>$wgPdfInfo = &#39;/opt/bin/pdfinfo&#39;;<br>$wgPdftoText = &#39;/opt/bin/pdftotext&#39;;</pre><p>3. Add following code at the bottom of LocalSettings.php.</p><pre>wfLoadExtension( &#39;PdfHandler&#39; );</pre><h3>VisualEditor</h3><p>1. If you’re using the latest stable version of MediaWiki you will not need to download the VisualEditor extension.</p><p>2. VisualEditor needs to be installed with:</p><pre>wfLoadExtension( &#39;VisualEditor&#39; );</pre><p>3. Allow VisualEditor on page titles containing slashes</p><p>If you are serving MediaWiKi from <strong>Apache2</strong>, you will need to add the following to your top level server configuration (often a &lt;VirtualHost&gt; section in /var/packages/Apache2.4/target/usr/local/etc/apache24/conf/httpd24.confor similar):</p><pre>AllowEncodedSlashes NoDecode</pre><p>If you do not, then VisualEditor will complain that Error contacting the Parsoid/RESTBase server when editing a page title containing a slash.</p><h3>SyntaxHighlight</h3><p>1. If you’re using the latest stable version of MediaWiki you will not need to download the SyntaxHighlight extension.</p><p>1.1 Otherwise, download <a href="https://www.mediawiki.org/wiki/Special:ExtensionDistributor?extdistname=SyntaxHighlight_GeSHi&amp;extdistversion=REL1_35">SyntaxHighlight extension</a> and extract the file(s) by tar in a directory called SyntaxHighlight_GeSHi in the extensions/ folder.</p><p>2. Add following code at the bottom of LocalSettings.php.</p><pre>wfLoadExtension( &#39;SyntaxHighlight_GeSHi&#39; );</pre><p>3. Install <strong>pip</strong>, the package installer for Python, and upgrade <strong>pip</strong> to the latest version.</p><pre>sudo -i<br>python3 -m ensurepip<br>python3 -m pip install --upgrade pip</pre><p>4. Install <a href="https://pygments.org/">Pygments</a> by <strong>pip</strong></p><pre>/var/packages/py3k/target/usr/local/bin/pip3 install Pygments</pre><p>5. Add following code in LocalSettings.php.</p><pre>$wgPygmentizePath = &quot;/var/packages/py3k/target/usr/local/bin/pygmentize&quot;;</pre><h3>Back up MediaWiKi</h3><p>Reference: <a href="https://www.mediawiki.org/wiki/Manual:Backing_up_a_wiki">Manual:Backing up a wiki</a></p><p>MediaWiki stores important data in two places:</p><p>1. Database: Pages and their contents, users and their syntaxhighlightferences, metadata, search index, etc.</p><p>2. File system: Software configuration files, custom skins, extensions, images (including deleted images), etc.</p><h4>MariaDB</h4><p>MySQL databases are easy to backup using the <strong>mysqldump</strong> command:</p><pre>mysqldump -u&lt;username&gt; -p&lt;password&gt; &lt;database name&gt; &gt; &lt;output file&gt;</pre><p>To restore a backup you will need to have a clean database. Then run:</p><pre>mysql -u&lt;username&gt; -p&lt;password&gt; &lt;database name&gt; &lt; &lt;input file&gt;</pre><p>You can also perform both of these tasks using phpMyAdmin</p><h4>File System</h4><p>MediaWiki stores other components of the wiki in the file system where this is more appropriate than insertion into the database, for example, site configuration files (LocalSettings.php, image files, skin customization, extension files, and etc.</p><pre>tar zcvhf mediawiki.tgz /volume1/mediawiki</pre><h3>Restore MediaWiKi</h3><p>Reference: <a href="https://www.mediawiki.org/wiki/Manual:Restoring_a_wiki_from_backup">Manual:Restoring a wiki from backup</a></p><h3>Namespace</h3><p>Reference: <a href="https://www.mediawiki.org/wiki/Manual:Using_custom_namespaces">Manual:Using custom namespaces</a></p><h4>Namespace</h4><pre>define(&quot;NS_WINDOWS&quot;, 3000);<br>define(&quot;NS_WINDOWS_TALK&quot;, 3001);<br>define(&quot;NS_MACOS&quot;, 3002);<br>define(&quot;NS_MACOS_TALK&quot;, 3003);<br>define(&quot;NS_LINUX&quot;, 3004);<br>define(&quot;NS_LINUX_TALK&quot;, 3005);</pre><pre>$wgExtraNamespaces[NS_WINDOWS] = &quot;Windows&quot;;<br>$wgExtraNamespaces[NS_WINDOWS_TALK] = &quot;Windows_Talk&quot;;<br>$wgExtraNamespaces[NS_MACOS] = &quot;macOS&quot;;<br>$wgExtraNamespaces[NS_MACOS_TALK] = &quot;macOS_Talk&quot;;<br>$wgExtraNamespaces[NS_LINUX] = &quot;Linux&quot;;<br>$wgExtraNamespaces[NS_LINUX_TALK] = &quot;Linux_Talk&quot;;</pre><pre>$wgNamespacesWithSubpages[NS_MAIN] = true;<br>$wgNamespacesWithSubpages[NS_WINDOWS] = true;<br>$wgNamespacesWithSubpages[NS_MACOS] = true;<br>$wgNamespacesWithSubpages[NS_LINUX] = true;</pre><pre>$wgContentNamespaces[] = NS_WINDOWS;<br>$wgContentNamespaces[] = NS_MACOS;<br>$wgContentNamespaces[] = NS_LINUX;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6ce37566e0e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mischievousboss/mediawiki-installation-a6ce37566e0e">MediaWiKi Installation</a> was originally published in <a href="https://medium.com/mischievousboss">MischievousBOSS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RouterOS 網路負載平衡]]></title>
            <link>https://medium.com/mischievousboss/routeros-%E7%B6%B2%E8%B7%AF%E8%B2%A0%E8%BC%89%E5%B9%B3%E8%A1%A1-e3bfdf936c64?source=rss----c874955c26c7---4</link>
            <guid isPermaLink="false">https://medium.com/p/e3bfdf936c64</guid>
            <category><![CDATA[routeros]]></category>
            <category><![CDATA[router]]></category>
            <category><![CDATA[network]]></category>
            <dc:creator><![CDATA[Mason Lyu]]></dc:creator>
            <pubDate>Sun, 04 Aug 2019 11:10:26 GMT</pubDate>
            <atom:updated>2019-08-04T11:10:55.785Z</atom:updated>
            <content:encoded><![CDATA[<p>Load Balancing — Pros &amp; Cons</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fUlFiklyA8VhRbtezB4_sA.jpeg" /></figure><p>在RouterOS中，所有的網路埠都可以設定成WAN或LAN，因此我們可以將其中幾個網路埠當成WAN來使用，這時候如果有申請不同網路服務商 (ISP) 的線路，就可以做網路負載平衡及備援。同一個ISP則意義不大，除非都是單獨拉專線，否則真要斷線也是一起斷。</p><p>要在RouterOS達到網路負載平衡 (Load Balancing)，最後一步一定是透過策略路由 (Policy Route) 來決定資料走向，但是要如何作分配呢？其中就有三種作法可以參考。至於RouterOS所有的方式則可以參考<a href="http://wiki.mikrotik.com/wiki/Load_Balancing">MikroTik Load Balancing</a>。</p><h3><strong>ECMP (Equal Cost Multi-Path)</strong></h3><p>有關ECMP的詳細步驟，可以參考<a href="http://wiki.mikrotik.com/wiki/ECMP_load_balancing_with_masquerade">MikroTik ECMP load balancing with masquerade</a>，主要是在Default Gateway將所有可連接的Gateway寫在一起</p><pre><em>/ip route <br>add dst-address=0.0.0.0/0 gateway=10.1.1.254,10.2.1.254,10.3.1.254 check-gateway=ping</em></pre><h4><strong>Pros</strong></h4><ul><li>擁有簡單的容錯移轉機制，一旦其中一條路徑斷了，自然改由其他剩餘有效路徑來平均分配</li></ul><h4><strong>Cons</strong></h4><ul><li>要特別注意並增加連線至RouterOS本身的Policy Route，因為來自A路徑的封包可能會經由B路徑出去，這時原本預計收到來自A路徑封包的設備會丟棄來自B路徑封包，造成連線失敗。</li><li>有些ISP內的主機（譬如DNS）僅提供給該ISP的線路，這時經由不同ISP線路出去的request可能不被接受。</li></ul><h3><strong>NTH &lt;第N個封包或連線&gt;</strong></h3><p>有關NTH的詳細步驟，可以參考<a href="https://wiki.mikrotik.com/wiki/NTH_load_balancing_with_masquerade">MikroTik NTH load balancing with masquerade</a>，主要是在防火牆標記這裡，指定封包或連線的次序。</p><p>譬如我們利用NTH=3,1來讓每三個封包中的第一個標記為Gateway_1；利用NTH=3,2來讓每三個封包中的第二個標記為Gateway_2；利用NTH=3,3來讓每三個封包中的第三個標記為Gateway_3</p><pre><em>/ip firewall mangle <br>add action=mark-packet chain=prerouting new-packet-mark=Gateway_1 nth=3,1 passthrough=yes<br>add action=mark-packet chain=prerouting new-packet-mark=Gateway_2 nth=3,2 passthrough=yes<br>add action=mark-packet chain=prerouting new-packet-mark=Gateway_3 nth=3,3 passthrough=yes</em></pre><p>或者也可以透過順序的調整，利用NTH=3,1來讓每三個封包中的第一個標記為Gateway_1；利用NTH=2,1來讓後面兩個封包中的第一個標記為Gateway_2，第二個標記為Gateway_3</p><pre><em>/ip firewall mangle <br>add action=mark-packet chain=prerouting new-packet-mark=Gateway_1 nth=3,1 passthrough=no<br>add action=mark-packet chain=prerouting new-packet-mark=Gateway_2 nth=2,1 passthrough=no<br>add action=mark-packet chain=prerouting new-packet-mark=Gateway_3</em></pre><h4><strong>Pros</strong></h4><ul><li>能完整的根據區網內的所有來源平均分配負載</li></ul><h4><strong>Cons</strong></h4><ul><li>區網內的Server對外服務要注意路徑</li><li>如果任何一條路徑斷了，其設定的路由標記將無作用，改由Default Route出去，增加Default Route的負載。</li></ul><h3><strong>PCC (Per Connection Classifier)</strong></h3><p>有關PCC的詳細步驟，可以參考<a href="http://wiki.mikrotik.com/wiki/Manual:PCC">MikroTik PCC</a>，如果想了解PCC運作原理，可以參考<a href="https://wiki.mikrotik.com/wiki/How_PCC_works_(beginner)">How PCC Works</a>，簡單說就是把Source IP、Source Port、Destination IP、Destination Port取需要的整數相加後，再將其總和的個位數除以指定值，而得到的餘數來作決定。</p><p>主要是在防火牆標記這裡，根據來源/目標的位置與埠的組合運算，來各別指定給予連線標記。</p><p>譬如我們將Source IP與Source Port相加後，其總和的個位數除以3得到的餘數若為0，則該連線標記為Gateway_1；若為1，則該連線標記為Gateway_2；若為2，則該連線標記為Gateway_3</p><pre><em>/ip firewall mangle <br>add action=mark-connection chain=prerouting new-connection-mark=Gateway_1 per-connection-classifier=src-address-and-port:3/0</em></pre><pre><em>add action=mark-connection chain=prerouting new-connection-mark=Gateway_2 per-connection-classifier=src-address-and-port:3/1</em></pre><pre><em>add action=mark-connection chain=prerouting new-connection-mark=Gateway_3 per-connection-classifier=src-address-and-port:3/2</em></pre><h4><strong>Pros</strong></h4><ul><li>因為判斷條件變化性多，當區網內設備夠多時，能以類似Random的方式動態平均分配負載</li></ul><h4><strong>Cons</strong></h4><ul><li>因為是採用餘數制，區網內設備少時，有機會負載集中落在其中幾條，譬如10.0.0.3:443與10.0.0.6:80就落在同一條。</li><li>如果任何一條路徑斷了，其設定的路由標記將無作用，改由Default Route出去，增加Default Route的負載。</li></ul><h4><strong>如果Gateway是同一個怎麼辦？</strong></h4><p>假如你申請了兩條線路，而ISP給你的Gateway是同一個，那麼當你在設定Route時，可以透過「%」符號重複指定不同的Routing Mark給同一個Gateway，譬如Gateway都是168.95.98.254</p><pre><em>/ip route<br>add gateway=168.95.98.254%WAN1 routing-mark=To_WAN1<br>add gateway=168.95.98.254%WAN2 routing-mark=To_WAN2</em></pre><p>相關範例可以參考<a href="https://wiki.mikrotik.com/wiki/Manual:Load_balancing_multiple_same_subnet_links">MikroTik Load balancing multiple same subnet links</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3bfdf936c64" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mischievousboss/routeros-%E7%B6%B2%E8%B7%AF%E8%B2%A0%E8%BC%89%E5%B9%B3%E8%A1%A1-e3bfdf936c64">RouterOS 網路負載平衡</a> was originally published in <a href="https://medium.com/mischievousboss">MischievousBOSS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RouterOS QoS]]></title>
            <link>https://medium.com/mischievousboss/routeros-qos-5a9eb83e4ef8?source=rss----c874955c26c7---4</link>
            <guid isPermaLink="false">https://medium.com/p/5a9eb83e4ef8</guid>
            <category><![CDATA[router]]></category>
            <category><![CDATA[network]]></category>
            <category><![CDATA[routeros]]></category>
            <dc:creator><![CDATA[Mason Lyu]]></dc:creator>
            <pubDate>Sun, 04 Aug 2019 10:56:04 GMT</pubDate>
            <atom:updated>2019-08-04T10:56:04.470Z</atom:updated>
            <content:encoded><![CDATA[<p>Queue / Hierarchical Token Bucket<strong> </strong>/ Per Connection Queue</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QHyyqeK0ilP4PLQtyRYzDg.jpeg" /></figure><p>QoS(服務質量)可設定使用者的網路使用類型來決定分配的頻寬，也可以設定重要的網路裝置取得較高的網路優先權。只要將某台電腦的上網優先權提高後，在網路頻寬吃緊的情況下 (譬如有另一台電腦在大量下載檔案)，依舊可以走優先通關通道，將頻寬資源優先分配給擁有高優先權的電腦，剩餘的頻寬才給另一台在大量下載檔案的電腦。</p><p>在討論RouterOS的QoS之前，有幾個名詞我們先來解析一下</p><h4><strong>Queue</strong></h4><p>佇列，透過一個先進先出(FIFO)的緩衝區，先把要送往外的封包儲存起來後再根據條件往外送出，可以用來限制頻寬。有關Queue的詳細說明，可以參考<a href="http://wiki.mikrotik.com/wiki/Manual:Queue">MirkoTik Queue</a></p><h4><strong>HTB (Hierarchical Token Bucket)</strong></h4><p>一個採優先權制的階層式佇列模式。依照優先權來決定，將擁有較高優先權的封包往外送。有關HTB的詳細說明，可以參考<a href="http://wiki.mikrotik.com/wiki/Manual:HTB">MikroTik Queue — HTB</a></p><h4><strong>PCQ (Per Connection Queue)</strong></h4><p>一種佇列的準則，用來動態平均分配頻寬給所有的使用者。有關PCQ的詳細說明，可以參考<a href="https://wiki.mikrotik.com/wiki/Manual:Queues_-_PCQ">MikroTik Queue — PCQ</a></p><p>我們這次要應用這些功能來實現QoS。在 [/queue] 裡面，共有三樣東西：</p><ol><li>/queue simple</li><li>/queue tree</li><li>/queue type</li></ol><p>先來說說 [/queue type]，這裡用來描述不同的佇列應用種類，除了預先設定的幾個之外，我們可以根據我們的需求來新增，這時我們先來設定兩個新的種類，並建構於PCQ這項演算法</p><pre>/queue type</pre><pre>add kind=pcq name=Download_PCQ pcq-classifier=dst-address pcq-limit=100 pcq-rate=300M pcq-total-limit=5000 pcq-src-address-mask=32 pcq-dst-address-mask=32 pcq-src-address6-mask=128 pcq-dst-address6-mask=128</pre><pre>add kind=pcq name=Upload_PCQ pcq-classifier=src-address pcq-limit=100 pcq-rate=100M pcq-total-limit=5000 pcq-src-address-mask=32 pcq-dst-address-mask=32 pcq-src-address6-mask=128 pcq-dst-address6-mask=128</pre><p>其中Download_PCQ的pcq-classifier=dst-address，表示我們要依據下載的目標地址來平均分配頻寬，也就是依據區網內每一台設備來分；而Upload_PCQ的pcq-classifier=src-address，表示我們要依據上傳的來源地址來平均分配頻寬，也是依據區網內每一台設備來分。</p><p>pcq-limit=100 代表每一台設備可以有100個封包的緩衝區，而pcq-total-limit=5000則表示我們最多支援50台設備。根據之前MikroTik提供的資料，緩衝區中每一個封包約需2200 bytes的儲存空間，因此pcq-total-limit=5000全用滿也就需要10.5MB的RAM，上傳加下載全用滿就需要21MB的RAM。有關pcq-limit設定值的影響，可以參考<a href="http://wiki.mikrotik.com/wiki/Manual:Queue_Size">MikroTik Queue Size</a></p><p>好，接下來我們來說說 [/queue simple] 及 [/queue tree] 的不同點，這時需要MikroTik的Packet Flow v6來幫忙 <a href="https://www.mobile01.com/redirect.php?url=http%3A%2F%2Fwiki.mikrotik.com%2Fimages%2Ff%2Ff3%2FPacketFlowDiagram_v6_c.svg">http://wiki.mikrotik.com/images/f/f3/PacketFlowDiagram_v6_c.svg</a></p><ol><li>Queue只發生在Input Chain及PostRouting Chain</li><li>[/queue tree] 限制過頻寬一次後，還會交由 [/queue simple] 再限制一次</li></ol><p>在 [/queue simple] 裡面的規則，是序列式處理，一條規則接著一條規則運行；在 [/queue tree] 裡面的規則，是平行式處理，整體而言處理速度較快也消耗較少系統資源。我們今天拿 [/queue tree] 來使用，因為 [/queue tree] 裡面的規則是根據每個封包的標記來決定要進行的動作，所以在設定 [/queue tree] 前，我們先來介紹 [/ip firewall mangle] 裡的 “mark packet” 與 “mark connection”</p><h4><strong>mark-connection與mark-packet</strong></h4><p>注意：封包中所有的標記只會留在RouterOS內使用，一旦離開RouterOS的範圍，封包中的任何標記將被移除</p><p>封包的標記，是針對每一個滿足條件的封包進行標記，也就是說條件設定的愈多，需要進行比對的動作也就愈多；條件設定的愈少，需要進行比對的動作也就愈少，換句話說</p><pre>/ip firewall mangle</pre><pre>add action=mark-packet chain=forward protocol=tcp dst-port=443 src-address=192.168.1.0/24 new-packet-mark=SSL out-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=forward protocol=tcp src-port=443 dst-address=192.168.1.0/24 new-packet-mark=SSL in-interface=PPPoE passthrough=no</pre><p>每個封包在forward chain時，就要比對是否是TCP？是否目的埠是443？是否來源地只是來自於192.168.1.0/24網段？是否out-interface是WAN？如果都是，則添加SSL標記到這個封包。這麼多的比對動作在forward chain的每個封包都要跑過一次。如果改成</p><pre>/ip firewall mangle</pre><pre>add action=mark-connection chain=forward protocol=tcp dst-port=443 src-address=192.168.1.0/24 new-connection-mark=SSL_conn out-interface=PPPoE</pre><pre>add action=mark-packet chain=forward connection-mark=SSL_conn new-packet-mark=SSL passthrough=no</pre><p>則當forward chain上的第一個封包因為符合TCP, port 443, 來自192.168.1.0/24, out-interface是PPPoE之後，會被冠上SSL_conn的連線標記，此後此連線上所有的封包都會自動冠上SSL_conn的連線標記。而在forward chain上的封包在做封包標記檢查時，只要確認這個封包是否有含SSL_conn連線標記，如果有則加上SSL封包標記。比對動作由原先的每個封包四個降到每個封包一個，大幅縮減系統資源。</p><h4><strong>Queue Tree</strong></h4><p>介紹完mark-connection與mark-packet，我們來進入Queue Tree，今天要介紹的一種通用的概念。Queue的優先權共分為8類，Priority設定由1~8，其中1代表最高優先級、8代表最低優先級。</p><pre>/queue tree<br>add max-limit=100M name=Total_Upload parent=global priority=1 queue=default</pre><pre>add max-limit=300M name=Total_Download parent=global priority=1 queue=default</pre><pre>add limit-at=270M max-limit=300M name=Download_Int parent=Total_Download priority=1 queue=default</pre><pre>add limit-at=30M max-limit=300M name=Download_NonInt parent=Total_Download queue=default</pre><pre>add limit-at=90M max-limit=100M name=Upload_Int parent=Total_Upload priority=1 queue=default</pre><pre>add limit-at=10M max-limit=100M name=Upload_NonInt parent=Total_Upload queue=default</pre><pre>add name=Download_Int_P1 packet-mark=Down_Int_P1 parent=Download_Int queue=Download_PCQ</pre><pre>add name=Download_Int_P2 packet-mark=Down_Int_P2 parent=Download_Int queue=Download_PCQ</pre><pre>add name=Download_Int_P3 packet-mark=Down_Int_P3 parent=Download_Int queue=Download_PCQ</pre><pre>add name=Download_Int_P4 packet-mark=Down_Int_P4 parent=Download_Int queue=Download_PCQ</pre><pre>add name=Download_Int_P5 packet-mark=Down_Int_P5 parent=Download_Int queue=Download_PCQ</pre><pre>add name=Download_Int_P6 packet-mark=Down_Int_P6 parent=Download_Int queue=Download_PCQ</pre><pre>add name=Download_Int_P7 packet-mark=Down_Int_P7 parent=Download_Int queue=Download_PCQ</pre><pre>add name=Download_Int_P8 packet-mark=Down_Int_P8 parent=Download_Int queue=Download_PCQ</pre><pre>add name=Download_NonInt_P1 packet-mark=Down_NonInt_P1 parent=Download_NonInt queue=Download_PCQ</pre><pre>add name=Download_NonInt_P2 packet-mark=Down_NonInt_P2 parent=Download_NonInt queue=Download_PCQ</pre><pre>add name=Download_NonInt_P3 packet-mark=Down_NonInt_P3 parent=Download_NonInt queue=Download_PCQ</pre><pre>add name=Download_NonInt_P4 packet-mark=Down_NonInt_P4 parent=Download_NonInt queue=Download_PCQ</pre><pre>add name=Download_NonInt_P5 packet-mark=Down_NonInt_P5 parent=Download_NonInt queue=Download_PCQ</pre><pre>add name=Download_NonInt_P6 packet-mark=Down_NonInt_P6 parent=Download_NonInt queue=Download_PCQ</pre><pre>add name=Download_NonInt_P7 packet-mark=Down_NonInt_P7 parent=Download_NonInt queue=Download_PCQ</pre><pre>add name=Download_NonInt_P8 packet-mark=Down_NonInt_P8 parent=Download_NonInt queue=Download_PCQ</pre><pre>add name=Upload_Int_P1 packet-mark=Up_Int_P1 parent=Upload_Int queue=Upload_PCQ</pre><pre>add name=Upload_Int_P2 packet-mark=Up_Int_P2 parent=Upload_Int queue=Upload_PCQ</pre><pre>add name=Upload_Int_P3 packet-mark=Up_Int_P3 parent=Upload_Int queue=Upload_PCQ</pre><pre>add name=Upload_Int_P4 packet-mark=Up_Int_P4 parent=Upload_Int queue=Upload_PCQ</pre><pre>add name=Upload_Int_P5 packet-mark=Up_Int_P5 parent=Upload_Int queue=Upload_PCQ</pre><pre>add name=Upload_Int_P6 packet-mark=Up_Int_P6 parent=Upload_Int queue=Upload_PCQ</pre><pre>add name=Upload_Int_P7 packet-mark=Up_Int_P7 parent=Upload_Int queue=Upload_PCQ</pre><pre>add name=Upload_Int_P8 packet-mark=Up_Int_P8 parent=Upload_Int queue=Upload_PCQ</pre><pre>add name=Upload_NonInt_P1 packet-mark=Up_NonInt_P1 parent=Upload_NonInt queue=Upload_PCQ</pre><pre>add name=Upload_NonInt_P2 packet-mark=Up_NonInt_P2 parent=Upload_NonInt queue=Upload_PCQ</pre><pre>add name=Upload_NonInt_P3 packet-mark=Up_NonInt_P3 parent=Upload_NonInt queue=Upload_PCQ</pre><pre>add name=Upload_NonInt_P4 packet-mark=Up_NonInt_P4 parent=Upload_NonInt queue=Upload_PCQ</pre><pre>add name=Upload_NonInt_P5 packet-mark=Up_NonInt_P5 parent=Upload_NonInt queue=Upload_PCQ</pre><pre>add name=Upload_NonInt_P6 packet-mark=Up_NonInt_P6 parent=Upload_NonInt queue=Upload_PCQ</pre><pre>add name=Upload_NonInt_P7 packet-mark=Up_NonInt_P7 parent=Upload_NonInt queue=Upload_PCQ</pre><pre>add name=Upload_NonInt_P8 packet-mark=Up_NonInt_P8 parent=Upload_NonInt queue=Upload_PCQ</pre><p>在這情況下，只要設定好packet-mark，自然會落入我們規劃好的優先權範圍內，所以在這之前，我們要先加入以下設定</p><pre>/ip firewall mangle<br>add action=mark-packet chain=prerouting connection-mark=Int_P1 new-packet-mark=Down_Int_P1 in-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=prerouting connection-mark=Int_P2 new-packet-mark=Down_Int_P2 in-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=prerouting connection-mark=Int_P3 new-packet-mark=Down_Int_P3 in-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=prerouting connection-mark=Int_P4 new-packet-mark=Down_Int_P4 in-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=prerouting connection-mark=Int_P5 new-packet-mark=Down_Int_P5 in-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=prerouting connection-mark=Int_P6 new-packet-mark=Down_Int_P6 in-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=prerouting connection-mark=Int_P7 new-packet-mark=Down_Int_P7 passthrough=no</pre><pre>add action=mark-packet chain=prerouting connection-mark=Int_P8 new-packet-mark=Down_Int_P8 in-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=prerouting connection-mark=NonInt_P1 new-packet-mark=Down_NonInt_P1 in-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=prerouting connection-mark=NonInt_P2 new-packet-mark=Down_NonInt_P2 in-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=prerouting connection-mark=NonInt_P3 new-packet-mark=Down_NonInt_P3 in-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=prerouting connection-mark=NonInt_P4 new-packet-mark=Down_NonInt_P4 in-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=prerouting connection-mark=NonInt_P5 new-packet-mark=Down_NonInt_P5 in-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=prerouting connection-mark=NonInt_P6 new-packet-mark=Down_NonInt_P6 in-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=prerouting connection-mark=NonInt_P7 new-packet-mark=Down_NonInt_P7 in-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=prerouting connection-mark=NonInt_P8 new-packet-mark=Down_NonInt_P8 in-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=postrouting connection-mark=Int_P1 new-packet-mark=Up_Int_P1 out-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=postrouting connection-mark=Int_P2 new-packet-mark=Up_Int_P2 out-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=postrouting connection-mark=Int_P3 new-packet-mark=Up_Int_P3 out-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=postrouting connection-mark=Int_P4 new-packet-mark=Up_Int_P4 out-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=postrouting connection-mark=Int_P5 new-packet-mark=Up_Int_P5 out-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=postrouting connection-mark=Int_P6 new-packet-mark=Up_Int_P6 out-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=postrouting connection-mark=Int_P7 new-packet-mark=Up_Int_P7 passthrough=no</pre><pre>add action=mark-packet chain=postrouting connection-mark=Int_P8 new-packet-mark=Up_Int_P8 out-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=postrouting connection-mark=NonInt_P1 new-packet-mark=Up_NonInt_P1 out-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=postrouting connection-mark=NonInt_P2 new-packet-mark=Up_NonInt_P2 out-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=postrouting connection-mark=NonInt_P3 new-packet-mark=Up_NonInt_P3 out-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=postrouting connection-mark=NonInt_P4 new-packet-mark=Up_NonInt_P4 out-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=postrouting connection-mark=NonInt_P5 new-packet-mark=Up_NonInt_P5 out-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=postrouting connection-mark=NonInt_P6 new-packet-mark=Up_NonInt_P6 out-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=postrouting connection-mark=NonInt_P7 new-packet-mark=Up_NonInt_P7 out-interface=PPPoE passthrough=no</pre><pre>add action=mark-packet chain=postrouting connection-mark=NonInt_P8 new-packet-mark=Up_NonInt_P8 out-interface=PPPoE passthrough=no</pre><p>在這樣的方式之下，我們不再針對每一個特定連線條件而單獨給它一個優先級，取而代之的是通用式，換句話說，我們會根據特定連線條件給封包一個落於上述區間的連線標記。舉個例子，假設要設定通過port 80的HTTP連線為優先級3，我們就可以這樣設定</p><pre><em>/ip firewall mangle<br>add action=mark-connection chain=forward dst-port=80 new-connection-mark=Int_P3 out-interface=PPPoE protocol=tcp</em></pre><p>又或者要設定BT的優先級是最低的，我們可以這樣設定</p><pre><em>/ip firewall mangle</em></pre><pre><em>add action=mark-connection chain=forward new-connection-mark=NonInt_P8 p2p=all-p2p</em></pre><pre><em>add action=mark-connection chain=forward dst-port=4662,16881 new-connection-mark=NonInt_P8 protocol=tcp</em></pre><pre><em>add action=mark-connection chain=forward dst-port=4672,6881 new-connection-mark=NonInt_P8 protocol=udp</em></pre><p>藉由這樣的方式，未來我們想針對某些條件設定優先權時，就可以只在mark-connection動手腳就好，此外，拿BT與HTTP來作示範，當有人在上網、有人在下載BT時，這是瀏覽網頁的優先權就會比下載BT的高，而當多人同時下載BT時，還記得我們在Queue Tree時的 [queue=Download_PCQ]嗎？每一台下載BT的設備也會取得平均分配的頻寬，而又不影響到其他人上網瀏覽網頁的權利，同時瀏覽網頁的所有設備也會取得平均分配的頻寬。</p><p>記憶體的使用，依照先前計算的若上傳加下載的PCQ要用掉21MB，我們在Queue Tree裡設定8組的Interactive及8組的Non-Interactive，如果全部用滿，則約需21MBx16=336MB的RAM。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a9eb83e4ef8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mischievousboss/routeros-qos-5a9eb83e4ef8">RouterOS QoS</a> was originally published in <a href="https://medium.com/mischievousboss">MischievousBOSS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RouterOS Stateless Tunnel]]></title>
            <link>https://medium.com/mischievousboss/routeros-stateless-tunnel-a5fd4b2dbc2c?source=rss----c874955c26c7---4</link>
            <guid isPermaLink="false">https://medium.com/p/a5fd4b2dbc2c</guid>
            <category><![CDATA[network]]></category>
            <category><![CDATA[routeros]]></category>
            <category><![CDATA[router]]></category>
            <dc:creator><![CDATA[Mason Lyu]]></dc:creator>
            <pubDate>Sun, 04 Aug 2019 10:30:44 GMT</pubDate>
            <atom:updated>2019-08-04T10:30:44.289Z</atom:updated>
            <content:encoded><![CDATA[<p>Ethernet over IP / IP over IP / Generic Routing Encapsulation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qXNm85P_ApeufQ6A" /><figcaption>Photo by <a href="https://unsplash.com/@cadop?utm_source=medium&amp;utm_medium=referral">Mathew Schwartz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>假設我們要將A-B兩地的網路連結在一起，形成一個更大的區域網路，除了使用虛擬私人網路 (VPN)外，在RouterOS裡還有三種方式可以實作，那就是EoIP (Ethernet over IP)、IPIP (IP over IP)與GRE (Generic Routing Encapsulation)</p><h3>Ethernet over IP</h3><p>詳細說明可參考<a href="http://wiki.mikrotik.com/wiki/Manual:Interface/EoIP">MikroTik EoIP</a>，單一端點設定如下，只要Tunnel-ID一樣，兩端就可以建立Transparent Bridge了。</p><pre>/interface eoip<br>add name=EoIP-Tunnel remote-address=”遠端固定Public IP地址” tunnel-id=123</pre><pre>/interface bridge<br>add name=EoIP-Bridge</pre><pre>/interface bridge port<br>add bridge=EoIP-Bridge interface=EoIP-Tunnel<br>add bridge=EoIP-Bridge interface=LAN</pre><p>此外，在建立Transparent Bridge的過程中，因為EoIP本身屬無加密傳輸，所以我們在建立通道之前，可以先建立加密通道(Site-to-Site VPN)，然後再於該加密通道上建立Transparent Bridge，譬如使用<strong>PPTP</strong></p><h4><strong>PPTP Server</strong></h4><pre>/interface pptp-server server<br>set enabled=yes</pre><pre>/ppp secret<br>add name=”使用者名稱” password=”使用者密碼” remote-address=10.0.0.2 local-address=10.0.0.1 profile=default-encryption</pre><h4><strong>PPTP Client:</strong></h4><pre>/interface pptp-client<br>add name=”pptp-tunnel1&quot; connect-to=“PPTP伺服器固定Public IP地址” user=”使用者名稱” password=”使用者密碼” profile=default-encryption add-default-route=no</pre><p>而EoIP中的”遠端固定Public IP地址”就是PPTP所設定的remote-address跟local-address。</p><h3><strong>IP over IP</strong></h3><p>詳細說明可參考<a href="http://wiki.mikrotik.com/wiki/Manual:Interface/IPIP">MikroTik IPIP</a>，單一端點設定如下</p><pre>/interface ipip<br>add name=IPIP-Tunnel remote-address=”遠端固定Public IP地址” local-address=”本地固定Public IP地址”</pre><pre>/ip address<br>add address=10.0.0.1/30 interface=IPIP-Tunnel</pre><pre>/ip route <br>add dst-address=遠端區網段 gateway=10.0.0.2</pre><h3><strong>Generic Routing Encapsulation</strong></h3><p>詳細說明可參考<a href="http://wiki.mikrotik.com/wiki/Manual:Interface/Gre">MikroTik GRE</a>，單一端點設定如下</p><pre>/interface gre<br>add name=GRE-Tunnel remote-address=”遠端固定Public IP地址” local-address=”本地固定Public IP地址”</pre><pre>/ip address <br>add address=10.1.0.1/30 interface=GRE-Tunnel</pre><pre>/ip route <br>add dst-address=遠端區網段 gateway=10.1.0.2</pre><h4>IP over IP與Generic Routing Encapsulation有何不同？</h4><p>詳細的說明，可以參考這篇文章<a href="https://packetlife.net/blog/2012/feb/27/gre-vs-ipip-tunneling/">GRE vs IPIP Tunneling</a>，但總括來說IP over IP只能封裝IP，而GRE可以封裝Layer 3所有的Protocol</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5fd4b2dbc2c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mischievousboss/routeros-stateless-tunnel-a5fd4b2dbc2c">RouterOS Stateless Tunnel</a> was originally published in <a href="https://medium.com/mischievousboss">MischievousBOSS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RouterOS VPN]]></title>
            <link>https://medium.com/mischievousboss/routeros-vpn-408c616b6582?source=rss----c874955c26c7---4</link>
            <guid isPermaLink="false">https://medium.com/p/408c616b6582</guid>
            <category><![CDATA[network]]></category>
            <category><![CDATA[routeros]]></category>
            <category><![CDATA[router]]></category>
            <dc:creator><![CDATA[Mason Lyu]]></dc:creator>
            <pubDate>Sat, 03 Aug 2019 15:48:05 GMT</pubDate>
            <atom:updated>2019-08-03T15:48:05.340Z</atom:updated>
            <content:encoded><![CDATA[<p>PPTP / L2TP / OpenVPN / SSTP / SSH Tunnel / IPSec / IKEv2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*knxogpWPsJ27f0z9" /><figcaption>Photo by <a href="https://unsplash.com/@lagopett?utm_source=medium&amp;utm_medium=referral">Petter Lagson</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>RouterOS支援非常多種的VPN協議，包括PPTP、L2TP、OpenVPN、SSTP、SSH Tunnel、IPSec與IKEv2等，除了支援點對站 (client-to-site)之外，也支援站對站 (site-to-site)。</p><p>點對站 (client-to-site)用於電腦或手機連線至RouterOS；而站對站 (site-to-site)則用於RouterOS連線至RouterOS。站對站 (site-to-site)就好像是建立起A-B兩地之間的虛擬私人網路。</p><p>這篇文章主要描述在RouterOS上，點對站 (client-to-site)的這種VPN協議設定方式。為了精確描述操作流程，以下將以CLI方式紀錄。</p><p>在RouterOS啟用這些VPN Server的同時，有以下幾個項目需要視個別情況作設定</p><pre>/ip pool<br>add name=VPN_Pool ranges=192.168.88.100–192.168.88.150<br>add name=OVPN_Pool ranges=192.168.88.32/30</pre><pre>/ppp profile<br>set [find name=default-encryption] dns-server=192.168.88.1 local-address=192.168.88.1 remote-address=VPN_Pool<br>add name=OpenVPN dns-server=192.168.88.1 local-address=192.168.88.32 remote-address=OVPN_Pool use-encryption=yes change-tcp-mss=yes</pre><pre>/ppp secret<br>add name=帳號 password=密碼 profile=default</pre><h3>PPTP</h3><p><em>Point to Point Tunneling Protocol</em>. 有關PPTP的詳細說明，可以參考<a href="http://wiki.mikrotik.com/wiki/Manual:Interface/PPTP">MikroTik PPTP</a></p><pre>/interface pptp-server server<br>set authentication=mschap2 default-profile=default-encryption enabled=yes</pre><pre>/ip firewall filter<br>add chain=input dst-port=1723 protocol=tcp<br>add chain=input protocol=gre</pre><p>PPTP的設定只要使用上面的CLI，基本上就可以連線了，在電腦或iOS裡面新增VPN，輸入帳號與密碼即可</p><h3><strong>L2TP over IPSec</strong></h3><p><em>Layer 2 Tunneling Protocol over Internet Protocol Security. </em>有關L2TP的詳細說明，可以參考<a href="http://wiki.mikrotik.com/wiki/Manual:Interface/L2TP">MikroTik L2TP</a></p><p>/interface l2tp-server server<br>set authentication=mschap2 enabled=yes</p><pre>/ip ipsec proposal<br>set [ find default=yes ] enc-algorithms=aes-128-cbc,aes-192-cbc,aes-256-cbc lifetime=8h pfs-group=none</pre><pre>/ip ipsec peer<br>add enc-algorithm=aes-128,aes-192,aes-256 exchange-mode=main-l2tp generate-policy=port-override lifetime=8h passive=yes secret=密鑰 send-initial-contact=no</pre><pre>/ip firewall filter<br>add chain=input dst-port=1701,500,4500 protocol=udp<br>add chain=input protocol=ipsec-esp</pre><p>L2TP/IPSec的設定只要使用上面的CLI，基本上就可以連線了，在電腦或iOS裡面新增VPN，輸入帳號、密碼與密鑰即可。</p><h4>-=Apple iOS額外注意事項=-</h4><p>在RouterOS上有一點要注意，因為當你使用以下CLI，若系統會自動幫你完成IPSec的設定，則IPSec中Peer的generate-policy要設成port-override，而以下CLI的預設值是port-strict</p><pre>/interface l2tp-server server<br>set authentication=mschap2 enabled=yes ipsec-secret=密鑰</pre><h3><strong>OpenVPN</strong></h3><p><em>Open Source VPN. </em>有關OpenVPN的詳細說明，可以參考<a href="http://wiki.mikrotik.com/wiki/Manual:Interface/OVPN">MikroTik OVPN</a></p><pre>/certificate<br>import file-name=OpenSSL_CA.crt<br>import file-name=OpenSSL_CA.key</pre><pre>/interface ovpn-server server<br>set auth=sha1 certificate=匯入OpenSSL_CA後的名稱 cipher=blowfish128,aes128,aes192,aes256 default-profile=OpenVPN enabled=yes</pre><pre>/ip firewall filter<br>add chain=input dst-port=1194 protocol=tcp</pre><p>RouterOS的設定按照以上CLI即可，而OpenVPN需要用到CA的Certificate與Private Key，這部份可以自己產生，利用NAS或是Linux/MacOS上的OpenSSL來跑，以下是範例，會產生上面CLI需要的OpenSSL_CA.key與OpenSSL_CA.crt。亦可以參考<a href="https://wiki.mikrotik.com/wiki/Manual:Create_Certificates#Generate_certificates_on_RouterOS">MikroTik Create Certificates</a></p><pre>openssl genrsa -des3 -out OpenSSL_CA.key 2048</pre><pre>openssl req -new -x509 -days 365 -key OpenSSL_CA.key -out OpenSSL_CA.crt</pre><p>然後在電腦端的採用以下設定就可以連線了 (RouterOS.ovpn)</p><pre>client<br>dev tun<br>proto tcp<br>remote 改成RouterOS的IP 1194<br>keepalive 10 120<br>auth SHA1<br>auth-user-pass<br>cipher AES-256-CBC<br>verb 5<br>redirect-gateway def1<br>dhcp-option DNS 8.8.4.4<br>ca OpenSSL_CA.crt</pre><p>若是要用iPhone/iPad連OpenVPN，則要再多以下步驟：</p><ul><li>產生iOS要用的Certificate與Private Key，這會需要用到剛剛CA的Certificate與Private Key</li></ul><pre>openssl genrsa -des3 -out iOS.key 2048</pre><pre>openssl req -new -key iOS.key -out iOS.csr</pre><pre>openssl x509 -req -days 365 -in iOS.csr -CA OpenSSL_CA.crt -CAkey OpenSSL_CA.key -set_serial 01 -out iOS.crt</pre><ul><li>設定檔改成如下所示 (iOS.ovpn)</li></ul><pre>client<br>dev tun<br>proto tcp<br>remote 改成RouterOS的IP 1194<br>keepalive 10 120<br>auth SHA1<br>auth-user-pass<br>verb 5<br>redirect-gateway def1<br>dhcp-option DNS 8.8.4.4<br>ca OpenSSL_CA.crt<br>cert iOS.crt<br>key iOS.key</pre><p>然後將<em>iOS.ovpn</em> / <em>iOS.crt</em> / <em>iOS.key</em> / <em>OpenSSL_CA.crt</em> 用iTunes匯入iOS裡的OpenVPN App</p><ul><li>或者設定檔改成如下所示 (Client.ovpn)</li></ul><pre>client<br>dev tun<br>proto tcp<br>remote 改成RouterOS的IP 1194<br>keepalive 10 120<br>auth SHA1<br>auth-user-pass<br>verb 5<br>redirect-gateway def1<br>dhcp-option DNS 8.8.4.4</pre><pre>&lt;ca&gt;<br> — — -BEGIN CERTIFICATE — — -<br>OpenSSL_CA.crt的內容<br> — — -END CERTIFICATE — — -<br>&lt;/ca&gt;<br>&lt;cert&gt;<br> — — -BEGIN CERTIFICATE — — -<br>iOS.crt的內容<br> — — -END CERTIFICATE — — -<br>&lt;/cert&gt;<br>&lt;key&gt;<br> — — -BEGIN RSA PRIVATE KEY — — -<br>iOS.key的內容<br> — — -END RSA PRIVATE KEY — — -<br>&lt;/key&gt;</pre><p>然後將<em>Client.ovpn</em>透過Email附件的方式由OpenVPN App開啟</p><ul><li>在iOS的設定-&gt;OpenVPN-&gt;Force AES-CBC ciphersuites，這個選項要關閉，因為OpenVPN App使用128-bit、CBC模式的Blowfish。若沒關閉則會發生Transport Error。</li><li>打開OpenVPN App，依序輸入使用者帳號、iOS.key的密碼(pass phrase, not challenge password)、使用者密碼，即可連線</li><li>如果不是完全依循上面的流程設定，而無法連線時，請看一下Log檔是否有出現以下訊息：</li></ul><blockquote>TUN Error: tun_prop_error: ifconfig addresses are not in the same /30 subnet (topology net30)</blockquote><p>這說明在使用OpenVPN連線時，Local Address與Remote Address不在同一個/30的子網域內，請修正</p><ul><li>Apple iOS 8+版本的iPhone/iPad可以開啟「Seamless tunnel」，這樣一來可以在暫停、恢復、重連線時仍維持VPN連線為有效狀態</li></ul><h3><strong>SSTP</strong></h3><p><em>Secure Socket Tunneling Protocol. </em>有關SSTP的詳細說明，可以參考<a href="http://wiki.mikrotik.com/wiki/Manual:Interface/SSTP">MikroTik SSTP</a></p><pre><em>/certificate<br>import file-name=StartSSL_CA.crt<br>import file-name=StartSSL_CA.key</em></pre><pre><em>/interface sstp-server server<br>set certificate=匯入StartSSL_CA後的名稱 default-profile=default-encryption enabled=yes force-aes=yes</em></pre><p>RouterOS的設定按照以上CLI即可，而SSTP需要用到CA的Certificate與Private Key，可以按照上面產生iOS用的Certificate與Private Key的方始產生，但是Client端就要匯入這些自行產生的憑證。</p><p>然後在電腦上透過SSTP連線軟體，輸入Domain name及帳號與密碼即可連線，注意一定要是Domain name而不是IP喔</p><h3><strong>SSH Tunnel</strong></h3><p><em>Secure Shell Tunnel. </em>有關SSH的詳細說明，可以參考<a href="http://wiki.mikrotik.com/wiki/Manual:Interface/SSH">MikroTik SSH</a></p><pre>/ip service<br>set ssh disabled=no</pre><pre>/ip ssh<br>set forwarding-enabled=yes</pre><p>RouterOS的設定按照以上CLI即可，主要是確定有開啟SSH服務及打開SSH的forward功能。接下來只要在電腦端設定好SOCKS Proxy即可連線，其中Proxy指向127.0.0.1而Port則指向PuTTY、iSSH(MacOS)、SSH Proxy(MacOS)設定的port</p><h3><strong>IPSec</strong></h3><p><em>Internet Protocol Security. </em><br>有關IPSec的詳細說明，可以參考<a href="http://wiki.mikrotik.com/wiki/Manual:IP/IPsec">MikroTik IPSec</a></p><pre>/ip ipsec mode-config<br>add address-pool=VPN_Pool name=Cisco_Mode split-include=其他Subnet</pre><pre>/ip ipsec policy group<br>add name=Cisco_Group</pre><pre>/ip ipsec proposal<br>set [ find default=yes ] enc-algorithms=aes-128-cbc,aes-192-cbc,aes-256-cbc \<br>lifetime=8h pfs-group=none</pre><pre>/ip ipsec peer<br>add auth-method=pre-shared-key-xauth enc-algorithm=aes-128,aes-192,aes-256 generate-policy=port-strict lifetime=8h mode-config=Cisco_Mode passive=yes policy-template-group=Cisco_Group secret=密鑰</pre><pre>/ip ipsec policy<br>add dst-address=VPN_Pool網段 group=Cisco_Group src-address=其他Subnet tunnel=yes template=yes<br>add dst-address=其他Subnet group=Cisco_Group src-address=VPN_Pool網段 tunnel=yes template=yes</pre><pre>/ip ipsec user<br>add name=帳號 password=密碼</pre><p>其中Mode Config、Policy Group、Policy Template是用來解決generate-policy所帶來的其他問題，譬如Client端可以產生任何Policy並存取任何區網段</p><h3><strong>IKEv2</strong></h3><p><em>Internet Key Exchange v2. </em>有關IKEv2的詳細說明，可以參考<a href="https://wiki.mikrotik.com/wiki/Manual:IP/IPsec#Ikev2_Server_Setup">MikroTik Road Warrior Setup IKEv2 RSA Auth</a></p><p>Step 1：建立Certificate，之前OpenVPN採用OpenSSL的方式來產生Certificate，這邊採用RouterOS內建的功能來作示範</p><pre>/certificate<br>add common-name=RouterOS_CA name=ROS_CA key-size=4096 days-valid=3650<br>sign ROS_CA ca-crl-host=RouterOS的IP</pre><pre>add common-name=RouterOS的FQDN subject-alt-name=IP:RouterOS的IP key-size=4096 days-valid=3650 key-usage=tls-server name=Server<br>sign Server ca=ROS_CA</pre><pre>add common-name=IKEv2_Client key-size=4096 days-valid=3650 key-usage=tls-client name=Client<br>sign Client ca=ROS_CA</pre><p>Step 2：設定IPSec</p><pre>/ip ipsec proposal<br>set [ find default=yes ] auth-algorithms=sha256,sha1 enc-algorithms=aes-128-cbc,aes-192-cbc,aes-256-cbc lifetime=8h pfs-group=none</pre><pre>/ip ipsec mode-config<br>add address-pool=VPN_Pool address-prefix-length=32 system-dns=yes name=IKEv2 split-include=其他Subnet</pre><pre>/ip ipsec peer<br>add auth-method=rsa-signature certificate=Server dh-group=modp2048 enc-algorithm=aes-256 exchange-mode=ike2 generate-policy=port-strict hash-algorithm=sha256 mode-config=IKEv2 passive=yes</pre><p>Step 3：匯出Certificate</p><pre>/certificate export-certificate ROS_CA</pre><pre>/certificate export-certificate Client export-passphrase=自行設定的密碼</pre><p>此時應該會產生三個檔案 cert_export_ROS_CA.crt, cert_export_Client.key, cert_export_Client.crt。這時我們需要使用額外的工具如OpenSSL來將.crt與.key的檔案轉換成PKCS12的格式(副檔名為.pfx)</p><pre>openssl pkcs12 -export -out RouterOS.pfx -inkey cert_export_Client.key -in cert_export_Client.crt -certfile cert_export_ROS_CA.crt</pre><p>Step 4：將產生的RouterOS.pfx與cert_export_ROS_CA.crt匯入手機或電腦(例如透過電子郵件寄送給自己後，在手機上打開，先安裝cert_export_ROS_CA.crt，再安裝RouterOS.pfx，這時需要輸入匯出Certificate時自行設定的密碼</p><p>Step 5：設定IKEv2 VPN，以Apple iOS為例<br>1. 類型：IKEv2<br>2. 描述：欲識別的名稱<br>3. 伺服器：RouterOS的FQDN或IP<br>4. 遠端識別碼：RouterOS的FQDN或IP<br>5. 本機識別碼：<br>6. 使用者認證：無<br>7. 使用憑證：啟用<br>8. 憑證：IKEv2_Client (產生憑證時所設定的Common Name)</p><p>然後就可以透過IKEv2 VPN連線了</p><h3>各種VPN協議比較</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hVoSACltRA80rNlLINhOzw.png" /><figcaption>VPN Protocol Comparison</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=408c616b6582" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mischievousboss/routeros-vpn-408c616b6582">RouterOS VPN</a> was originally published in <a href="https://medium.com/mischievousboss">MischievousBOSS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RouterOS — 功能強大的軟體路由系統]]></title>
            <link>https://medium.com/mischievousboss/routeros-%E5%8A%9F%E8%83%BD%E5%BC%B7%E5%A4%A7%E7%9A%84%E8%BB%9F%E9%AB%94%E8%B7%AF%E7%94%B1%E7%B3%BB%E7%B5%B1-2ba758f04530?source=rss----c874955c26c7---4</link>
            <guid isPermaLink="false">https://medium.com/p/2ba758f04530</guid>
            <category><![CDATA[network]]></category>
            <category><![CDATA[routeros]]></category>
            <category><![CDATA[router]]></category>
            <dc:creator><![CDATA[Mason Lyu]]></dc:creator>
            <pubDate>Sat, 03 Aug 2019 13:21:33 GMT</pubDate>
            <atom:updated>2019-08-03T14:56:57.080Z</atom:updated>
            <content:encoded><![CDATA[<h3>RouterOS — 功能強大的軟體路由系統</h3><p>還在尋找合適的路由器嗎？那你不能不知道RouterOS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EaQHHS0Utkn8hrLi" /><figcaption>Photo by <a href="https://unsplash.com/@isodme?utm_source=medium&amp;utm_medium=referral">Jonathan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>什麼？你不知道什麼叫做<strong>路由器 (Router)</strong>！沒關係，你一定聽過<strong>IP分享器</strong>，對吧？其實你所認知的IP分享器實際上就是在做路由器的事情。</p><h4>什麼是路由器？</h4><p>在網路世界裡，遠端的資料(譬如網頁內容)要送到你手邊，中間要經過非常多的<strong>節點。</strong>舉個例子，假如你今天要飛到歐洲的一個小國家，沒有直飛的班機，就需要經過多次的轉機，而這些轉機時的機場，就好比網路的節點。下一段旅程要先飛到哪一個機場(節點)，才能到達目的地？</p><p>路由器所做的事情，就是在每個節點上，正確地把遠端的資料轉送到能通往目的地的下一個節點，最後到達你手邊的電腦或手機。因此，當你在室內上網，最後一個節點就是你身邊的IP分享器(路由器)。</p><h4>IP分享器(路由器) — 硬體與軟體的不同</h4><p>平常我們在買的IP分享器(路由器)，不外乎就是知名品牌大廠的這些產品。你買了一個IP分享器(路由器)回來，拉一條網路線接在網路服務商(ISP)的數據機(Modem)後面，透過網頁的方式做些簡單的設定，然後它就成為了一個網路上的節點。</p><p>一般來說，根據每個廠商所開發的功能，IP分享器(路由器)所支援的功能都是固定的，這些產品我們對它簡稱硬體路由，實際上它由硬體與固定功能的軟體組成。</p><p>但是你知道還有一種<strong>軟體路由系統</strong>嗎？它就像是一套作業系統(譬如Windows或macOS)，可以安裝在電腦上，然後讓你的電腦提供IP分享器(路由器)的功能。由於硬體可以自由選擇(因為每一台電腦的配置都可以不同)，所以我們簡稱這套作業系統為<strong>軟體路由系統</strong>。也因為硬體可以自由配置，所以再也不必受限於品牌廠的產品限制，想讓你的IP分享器(路由器)有多強大就能多強大。</p><h3>RouterOS by MikroTik</h3><p>軟體路由系統有許多廠商在提供各自的一套系統，其中一套就是由位在歐洲拉脫維亞(Latvia)的<a href="https://mikrotik.com/">MikroTik</a>公司所設計的<a href="https://mikrotik.com/software">RouterOS</a>，是一套用於網路系統的作業系統，它支援非常多的功能，其功能強大到甚至超越市場上售價昂貴的路由器。</p><p>RouterOS是根據於Linux作業系統改寫而來，可安裝於標準的x86平台或MikroTik 公司的 RouterBoard 硬體產品上。支援的功能包括有路由設定(Routing)、防火牆 (Firewall)、虛擬私人網絡 (VPN)、虛擬區域網路 (VLAN)、頻寬限制管理 (QoS)、DHCP服務器 (IP分享)、多廣域網路 (multi-WAN)與頻寬負載平衡 (Load balance)。</p><h4>多廣域網路 (multi-WAN)與頻寬負載平衡 (Load balance)</h4><p>我們先來談談多廣域網路 (multi-WAN)。當你今天同時申請了多家網路服務商的線路，譬如中華光世代 + 凱擘大寬頻，如果想要整合這些外部線路，讓他們提供備援的功用 (所謂備援就是當一家線路斷線時，另一家的線路仍能同時支援上網服務)，就需要多廣域網路 (multi-WAN)功能。</p><p>由於RouterOS可以自由將每一個網路埠設定為內部線路的LAN埠或是外部線路的WAN埠，所以設定多個網路埠為WAN埠後，各別連接不同網路服務商的數據機 (Modem)，而RouterOS可以將它們整合在一起，提供2~3倍的網路頻寬。</p><p>此外，在所有外部線路皆正常通訊的情況下，RouterOS還可以提供頻寬負載平衡 (Load balance)功能。讓多條外部線路可以同時分配到大致相等的資料傳輸。舉個例子，就好像三線道的大馬路，汽車(資料)可以平均跑在每一線道上，而不是通通塞在快車道或慢車道。</p><h4>DHCP服務器 (IP分享)</h4><p>DHCP服務器所提供的功能就是作為IP分享。每一個上網設備都需要有一個獨立的IP，而DHCP服務器就是當有一個設備需要上網時，提供一個區域網路內的IP。</p><p>不只這樣，透過路由標籤 (Routing Mark) 的設定，RouterOS還可以指定在區域網路內的不同設備，自動選擇合適的外部線路或是特定的外部線路，譬如電腦全部走中華光世代上網，而手機全部走凱擘大寬頻上網。</p><h4>虛擬區域網路 (VLAN)</h4><p>虛擬區域網路 (VLAN)可能很多人沒聽過，它的作用就是在區域網路內再分出一組或多組的封閉網路，隸屬於相同虛擬區域網路 (VLAN)的成員可以互相通訊，外部成員則看不到也連線不到這些設備。</p><p>虛擬區域網路 (VLAN)的另一個應用在哪裡？就是中華電信MOD。中華電信MOD一般來說都要直接透過網路線接在中華電信數據機 (Modem)後面，但這在某些環境下時常造成困擾。假如你的數據機跟MOD距離遙遠，或是樓上樓下的關係，單拉一條網路線並不方便，這時只要將MOD連接RouterOS設備，搭配支援虛擬區域網路 (VLAN)的交換機 (Switch)，你的MOD愛放哪就放哪。</p><h3>在有限的預算下，提供強大的功能</h3><p>一開始會關注到RouterOS，無非也是因為現有產品無法提供足夠的功能，好啦，我說的現有產品是指在PCHome或是Momoshop上能買到的IP分享器，Cisco等專業網通產品已經大幅超過我的預算，我想一般人非公司戶也不會花大錢去買Cisco這類的產品，可是我又想要有進階的功能怎麼辦？</p><p>在一次偶然的機緣下，知道了有<strong>軟體路由系統</strong>這樣的產品，在經過一段時間的Google之後，發現到RouterOS這樣的好東西，而且RouterOS有非常詳盡的<a href="https://wiki.mikrotik.com/wiki/Manual:TOC">線上使用手冊</a>與範例，透過MikroTik所提供的線上資源，新手也可以變老手，透過RouterOS完成強大的網路設定。</p><p>如果你也跟我一樣無法滿足於市面上的IP分享器(路由器)所提供的功能，也沒有太多的預算去換用Cisco等專業網通大廠的產品，那麼，RouterOS會是一個好的選擇。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ba758f04530" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mischievousboss/routeros-%E5%8A%9F%E8%83%BD%E5%BC%B7%E5%A4%A7%E7%9A%84%E8%BB%9F%E9%AB%94%E8%B7%AF%E7%94%B1%E7%B3%BB%E7%B5%B1-2ba758f04530">RouterOS — 功能強大的軟體路由系統</a> was originally published in <a href="https://medium.com/mischievousboss">MischievousBOSS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>