<?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>yurisk.info &#187; Fortigate</title>
	<atom:link href="http://yurisk.info/tag/fortigate/feed/" rel="self" type="application/rss+xml" />
	<link>http://yurisk.info</link>
	<description>Technical Blog about IT Security and Networking</description>
	<lastBuildDate>Tue, 07 Sep 2010 12:42:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>MAC finder script</title>
		<link>http://yurisk.info/2010/07/02/mac-finder-script/</link>
		<comments>http://yurisk.info/2010/07/02/mac-finder-script/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 05:35:37 +0000</pubDate>
		<dc:creator>Yuri</dc:creator>
				<category><![CDATA[Checkpoint NG/NGX]]></category>
		<category><![CDATA[Cisco]]></category>
		<category><![CDATA[Esafe]]></category>
		<category><![CDATA[Fortigate]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[Checkpoint]]></category>

		<guid isPermaLink="false">http://yurisk.info/?p=959</guid>
		<description><![CDATA[While I don&#8217;t like going down to Layer 2 , recently I had to do it &#8211; I didn&#8217;t know IP address of the Cisco router I wanted to connect to but I had access to the Cisco router sitting in the same network. That would be pretty easy to do #show arp on this [...]]]></description>
			<content:encoded><![CDATA[<p>While I don&#8217;t like going down to Layer 2 , recently I had to do it &#8211; I didn&#8217;t know IP address of the Cisco router I wanted to connect to but I had access to the Cisco router sitting in the same network. That would be pretty easy to do #show arp on this router and then search on Google to whom belongs each MAC  if it wasn&#8217;t the subnet mask of /26. Copy pasting each entry of the ARP table into Google didn&#8217;t look like a lot of fun. So I wrote a python script that reads MAC addresses in bulk from command line and using downloaded beforehand database of MAC-vendor translations prints vendor for each MAC address. It works for &#35;show arp on CIsco,&#35;show mac-address-table on CIsco switches, &#35;arp -en  on Linux (means including Checkpoint), &#35;arp -a on Freebsd ,&#35;show arp of Junos from Juniper, &#35;get sys arp on Fortigate.<br />
Below is the script.<br />
Here&#58;<br />
<strong>mac-database.txt</strong> &#8211; file containing MAC-vendor translation in format &lt;MAC 6 hex digits as a sequence&gt; &lt;VENDOR&gt;, I used <a href="http://standards.ieee.org/regauth/oui/oui.txt"> standards.ieee.org/regauth/oui/oui.txt </a> as the source with a bit of sed, but if you want ready to use file I recommend <strong>nmap-mac-prefixes</strong> from nmap source-code distribution <a href="http://nmap.org/svn/nmap-mac-prefixes">http://nmap.org/svn/nmap-mac-prefixes</a><br />
Download script (to make sure formatting is preserved, an important thing for Python)<br />
<a href="http://yurisk.info/scripts/mac-finder.py">http://yurisk.info/scripts/mac-finder.py</a><br />Script AND mac database from nmap project &#8211; <a href="http://yurisk.info/scripts/mac.tar.gz"> http://yurisk.info/scripts/mac.tar.gz</a></p>
<div class="cmdout">
<pre>
&#35;!/usr/bin/python
&#35;This script accepts MAC addresses from the command line and
&#35;prints vendor for each mac address
&#35; Author&#58;Yuri, yurisk@yurisk.info,06.2010
import sys
import re
&#35;This function removes from MACs colon or dot and returns MAC as a sequence of HEX chars
def dotreplace(matchobj):
&nbsp;&nbsp;       if matchobj.group(0) == &#39;.&#39;&#58;
&nbsp;&nbsp;&nbsp;&nbsp;            return &#39;&#39;
&nbsp;&nbsp;       elif  matchobj.group(0) == &#39;&#58;&#39;&#58;
&nbsp;&nbsp;&nbsp;&nbsp;            return &#39;&#39;
&#35;open file with MAC addresses and vendors database,it has form xxxx &lt;Vendor&gt;
macs=open(&#39;mac-database.txt&#39;,&#39;r&#39;)
macs_lines=macs.readlines()
&#35;Read from stdinput
data = sys.stdin.readlines()
for ppp in data:
       popa=re.search(&#39;.*([a-f0-9]{4}\.[a-f0-9]{4}\.[a-f0-9]{4}).*&#39;,ppp,re.IGNORECASE)
       if popa:
             newpopa=re.sub(&#39;\.&#39;, dotreplace,popa.group(1))[0:6]
             newpopa_re=re.compile(newpopa,re.IGNORECASE)
             for mac_db in macs_lines:
                 vendor=re.search(newpopa_re,mac_db)
                 if vendor:
                    print ppp.strip(),mac_db[7:]
       popalinux = re.search(&#39;.*([a-f0-9]{2}&#58;[a-f0-9]{2}&#58;[a-f0-9]{2}&#58;[a-f0-9]{2}&#58;[a-f0-9]{2}&#58;[a-f0-9]{2}).*&#39;,ppp,re.IGNORECASE)
       if popalinux&#58;
             newpopalinux=re.sub(&#39;&#58;&#39;,dotreplace,popalinux.group(1))[0&#58;6]
             newpopalinux_re=re.compile(newpopalinux,re.IGNORECASE)
             for mac_db in macs_lines&#58;
                 vendor=re.search(newpopalinux_re,mac_db)
                 if vendor&#58;
                    print ppp.strip(),mac_db[7&#58;]

       popadash = re.search('.*([a-f0-9]{2}-[a-f0-9]{2}-[a-f0-9]{2}-[a-f0-9]{2}-[a-f0-9]{2}-[a-f0-9]{2}).*',ppp,re.IGNORECASE)
       if popadash:
             newpopadash=re.sub('-',dotreplace,popadash.group(1))[0:6]
             newpopadash_re=re.compile(newpopadash,re.IGNORECASE)
             for mac_db in macs_lines:
                 vendor=re.search(newpopadash_re,mac_db)
                 if vendor:
                    print ppp.strip(),mac_db[7:]
</pre>
</div>
<p>Running it:</p>
<div class="cmd">
[root@darkstar ]# ./mac-finder.py</div>
<div class="cmdout">
&lt;now I copy paste output from arp -a in BSD&gt;<br />$ arp -a<br />
(10.99.99.150) at 00:50:56:95:74:72 on em0 [ethernet]<br />
 (10.99.99.254) at 00:09:0f:31:c8:24  on em0 [ethernet]<br /> &lt;Hit CTRL+D to signal the end of input&gt;<br />
 (10.99.99.150) at 00:50:56:95:74:72 on em0 [ethernet] VMware, Inc.<br />
 (10.99.99.254) at 00:09:0f:31:c8:24 on em0 [ethernet] Fortinet Inc.</div>
]]></content:encoded>
			<wfw:commentRss>http://yurisk.info/2010/07/02/mac-finder-script/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fortigate BGP &#8211; configure and debug</title>
		<link>http://yurisk.info/2010/03/26/fortigate-bgp-configure-and-debug/</link>
		<comments>http://yurisk.info/2010/03/26/fortigate-bgp-configure-and-debug/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 14:56:12 +0000</pubDate>
		<dc:creator>Yuri</dc:creator>
				<category><![CDATA[Firewall]]></category>
		<category><![CDATA[Fortigate]]></category>

		<guid isPermaLink="false">http://yurisk.info/?p=647</guid>
		<description><![CDATA[Everyone today speaks BGP: Cisco routers, Juniper routers and ScreenOS firewalls, Fortigate does it,even SonicWall have it as planned feature So question is not whether but how. The opportunity to see how it works on Fortigate recently presented itself and here is the sum up of how I configured and debugged Fortigate BGP set up. [...]]]></description>
			<content:encoded><![CDATA[<p>Everyone today speaks BGP: Cisco routers, Juniper routers and ScreenOS firewalls, Fortigate does it,even SonicWall  have it  as planned feature  So question is not whether but how. The opportunity to see how it works on Fortigate recently presented itself and here is the sum up of how I configured and debugged Fortigate BGP set up.<br />
Task at hand: configure BGP peering with Bogon Route project by Team Cymru <a href="http://www.team-cymru.org/Services/Bogons/routeserver.html"> www.team-cymru.org/Services/Bogons/routeserver.html </a> . More information about the Bogon Routes can be found at the source &#8211; <a href="http://www.team-cymru.org/Services/Bogons/">www.team-cymru.org/Services/Bogons </a>. But in few words they advertise to you routes that are never to be seen in your network for legitimate reasons. Those are networks not only from RFC 1918 but those reserved by RIPE for special purposes, and those unallocated to anyone as of now.<br />
 What we need to know for this set up is this:</p>
<ul>
<li>They advertise all the networks with no-export community</li>
<li>also they attach 65333:888  community (as per their site)</li>
<li>they use md5 password authentication </li>
<li>they don&#8217;t expect you to advertise to them anything</li>
<li>in advertised networks next hop is their advertising router </li>
<li>their AS number is 65333</li>
</ul>
<p>Based on all the above my Fortigate BGP peer had to :</p>
<ul>
<li>enable multihop peering</li>
<li>use MD5 password authentication</li>
<li>have route-map to attach no-export community so that we don&#8217;t  inadvertently advertise learned routes to other peers ( just safety net , in case BGP peer stops attaching no-export community to their routes) </li>
<li>set next hop for the learned routes to Null 0 interface.</li>
</ul>
<p>Let&#8217;s start configuring something. Important surprise here – in Fortigate GUI you can only set  3 parameters:<br />
<i>As number , Peer Ip</i> and <i>networks</i> to be advertised, the rest is to be done on the  command line . So here it goes<br />
1) Configuring route-map to set no-export community on learned networks and force next hop to be some reserved Ip (192.0.2.1 )  that in turn is statically routed to Null interface ,</p>
<div class="cmd">config router route-map<br />
    edit &#8220;NO-EXPORT&#8221;<br />
            config rule<br />
                edit 3<br />
                    set set-community &#8220;no-advertise&#8221;<br />
                    set set-ip-nexthop 192.0.2.1<br />
                next<br />
            end<br />
    next<br />
End </div>
<p>2) Configure BGP peer</p>
<div class="cmd">(root) # show router bgp<br />
config router bgp<br />
    set as 65002<br />
        config neighbor<br />
            edit 84.22.96.5<br />
                set ebgp-enforce-multihop enable<br />
                set remote-as 65333<br />
                set route-map-in &#8220;NO-EXPORT&#8221;<br />
                set password &#8220;yuiyui&#8221;<br />
            next<br />
        end<br />
        config redistribute &#8220;connected&#8221;<br />
            set status enable<br />
        end</div>
<p>3) Configure static blackhole route for the reserved IP used as the next hop for this.</p>
<div class="cmd">(root) # sh router static<br />
config router static<br />
        edit 3<br />
        set blackhole enable<br />
        set dst 192.0.2.1 255.255.255.255<br />
    next<br />
End</div>
<p>Validation phase.<br />
All configs are as good as the prove that it works.</p>
<p> List shortly all the peers </p>
<div class="cmd">(root) # get router info bgp summary</div>
<pre>BGP router identifier 10.250.250.2, local AS number 65002
BGP table version is 159
2 BGP AS-PATH entries
0 BGP community entries

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
84.22.96.5   4  65333       4       6      159    0    0 00:00:48        0

Total number of neighbors 1 </pre>
<p>List all BGP neighbors and their peering state</p>
<div class="cmd">My-FG (root) # get router info bgp neighbors</div>
<pre>
BGP neighbor is 84.22.96.5, remote AS 65333, local AS 65002, external link
  BGP version 4, remote router ID 84.22.96.5
  BGP state = Established, up for 00:00:58
  Last read 00:00:58, hold time is 180, keepalive interval is 60 seconds
  Configured hold time is 180, keepalive interval is 60 seconds
  Neighbor capabilities:
    Route refresh: advertised and received (old and new)
    Address family IPv4 Unicast: advertised and received
  Received 4 messages, 0 notifications, 0 in queue
  Sent 6 messages, 0 notifications, 0 in queue
  Route refresh request: received 0, sent 0
  Minimum time between advertisement runs is 30 seconds

 For address family: IPv4 Unicast
  BGP table version 160, neighbor version 159
  Index 3, Offset 0, Mask 0x8
  Community attribute sent to this neighbor (both)
  Inbound path policy configured
  Route map for incoming advertisements is *NO-EXPORT
  0 accepted prefixes
  19 announced prefixes
  Connections established 1; dropped 0
  External BGP neighbor may be up to 255 hops away.
Local host: 10.250.250.2, Local port: 9188
Foreign host: 84.22.96.5, Foreign port: 179
Nexthop: 10.250.250.1</pre>
<p> See the routes learned through the BGP protocol</p>
<div class="cmd">(root) #  get router info bgp network</div>
<pre>
BGP table version is 161, local router ID is 10.250.250.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 5.0.0.0          192.0.2.1                0             0 65333 65333 i
*> 14.0.0.0         192.0.2.1                0             0 65333 65333 i
*> 23.0.0.0         192.0.2.1                0             0 65333 65333 i
*> 31.0.0.0         192.0.2.1                0             0 65333 65333 i
*> 36.0.0.0         192.0.2.1                0             0 65333 65333 i
*> 37.0.0.0         192.0.2.1                0             0 65333 65333 i
*> 39.0.0.0         192.0.2.1                0             0 65333 65333 i
*> 42.0.0.0         192.0.2.1                0             0 65333 65333 i
*> 49.0.0.0         192.0.2.1                0             0 65333 65333 i
*> 100.0.0.0        192.0.2.1                0             0 65333 65333 i
*> 101.0.0.0        192.0.2.1                0             0 65333 65333 i
*> 102.0.0.0        192.0.2.1                0             0 65333 65333 i
*> 103.0.0.0        192.0.2.1                0             0 65333 65333 i
*> 104.0.0.0        192.0.2.1                0             0 65333 65333 i
*> 105.0.0.0        192.0.2.1                0             0 65333 65333 i
*> 106.0.0.0        192.0.2.1                0             0 65333 65333 i
*> 169.254.0.0      192.0.2.1                0             0 65333 65333 i
*> 172.16.0.0/12    192.0.2.1                0             0 65333 65333 i
*> 176.0.0.0/8      192.0.2.1                0             0 65333 65333 i
*> 177.0.0.0/8      192.0.2.1                0             0 65333 65333 i
*> 179.0.0.0/8      192.0.2.1                0             0 65333 65333 i
*> 181.0.0.0/8      192.0.2.1                0             0 65333 65333 i
*> 185.0.0.0/8      192.0.2.1                0             0 65333 65333 i
 </pre>
<p>List routes that are currently installed in the routing table that were learned by BGP .</p>
<div class="cmd">(root) # get router info routing-table bgp</div>
<pre>
B       5.0.0.0/8 [20/0] via 192.0.2.1 (recursive is directly connected, unknown), 00:00:19
B       14.0.0.0/8 [20/0] via 192.0.2.1 (recursive is directly connected, unknown), 00:00:19
B       23.0.0.0/8 [20/0] via 192.0.2.1 (recursive is directly connected, unknown), 00:00:19
B       31.0.0.0/8 [20/0] via 192.0.2.1 (recursive is directly connected, unknown), 00:00:19
B       36.0.0.0/8 [20/0] via 192.0.2.1 (recursive is directly connected, unknown), 00:00:19
B       37.0.0.0/8 [20/0] via 192.0.2.1 (recursive is directly connected, unknown), 00:00:19
B       39.0.0.0/8 [20/0] via 192.0.2.1 (recursive is directly connected, unknown), 00:00:19
B       42.0.0.0/8 [20/0] via 192.0.2.1 (recursive is directly connected, unknown), 00:00:19
</pre>
<p>After all is configured and saved (and probably doesn&#8217;t work) comes the bgp debug round.<br />
Enable bgp debug on the appliance</p>
<div class="cmd">#diag ip router bgp all enable</div>
<p>Enable debug output to console</p>
<div class="cmd">diag debug enable</div>
<p>To stop this output </p>
<div class="cmd">diagnose  debug disable</div>
<p>To verify that debug is on</p>
<div class="cmd"># diag ip router bgp show</div>
<pre>BGP debugging status:
  BGP events debugging is on
  BGP debug level: INFO </pre>
<p>If nothing after that happens try clearing all BGP sessions</p>
<div class="cmd">#exec router clear bgp all</div>
<p>The good way to judge something new is to compare it with something you already know. To continue<br />
With that logic I cross-reference debug output seen on Fortigate with the one seen on the Cisco BGP peer. That<br />
way you  can decide what is more informative and who wins the race (Cisco of course, what you thought?). </p>
<p> <strong>Case 1</strong><br />
<u>One of the peers is configured with wrong AS number.</u><br />
In Fortigate you see this:</p>
<pre>BGP: 84.22.96.5-Outgoing [FSM] State: Idle Event: 3
BGP: 84.22.96.5-Outgoing [NETWORK] FD=15, Sock Status: 0-Success
BGP: 84.22.96.5-Outgoing [FSM] State: Connect Event: 17
BGP: 84.22.96.5-Outgoing [ENCODE] Msg-Hdr: Type 1
BGP: 84.22.96.5-Outgoing [ENCODE] Open: Ver 4 MyAS 65002 Holdtime 180
BGP: 84.22.96.5-Outgoing [ENCODE] Open: Msg-Size 45
BGP: 84.22.96.5-Outgoing [DECODE] Msg-Hdr: type 3, length 23
BGP: %BGP-3-NOTIFICATION: received from 84.22.96.5 2/2 (OPEN Message Error/Bad Peer AS.) 2 data-bytes
</pre>
<p>Now let&#8217;s compare to the debug from Cisco</p>
<div class="cmd">#debug ip bgp events  </div>
<pre>
Mar 24 13:14:55.572: %BGP-3-NOTIFICATION: sent to neighbor 10.250.250.2 2/2 (peer in wrong AS) 2 bytes FDEA FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF 002D 0104 FAEA 01B4 0AFA EA02 1302 0201 1400 0100 0132 0222 0012 0222 00
</pre>
<p><strong>Case 2</strong><br />
<u>MD5 authentication is set on Cisco but not on the Fortigate.</u> Again for comparison<br />
debug from Fortigate and debug from Cisco<br />
Cisco:</p>
<pre>Jan  5 10:42:14.299: %TCP-6-BADAUTH: No MD5 digest from 10.250.250.2 (1037) to 84.22.96.5(179)</pre>
<p>Fortigate:</p>
<pre>
84.22.96.5-Outgoing [FSM] State: Connect Event: 9
BGP: [RIB] Scanning BGP Network Routes...
84.22.96.5-Outgoing [FSM] State: Connect Event: 9
BGP: [RIB] Scanning BGP Network Routes...
</pre>
<p><strong>Case 3 </strong><u> (that actually happened when I configured this Fortigate) is mismatched MD5 password on either side</u></p>
<p>Fortigate:<br />
Doing summary listing showed peering as down :</p>
<pre>84.22.96.5   4  65333     934    1036        0    0    0    never Connect </pre>
<p>Cisco:</p>
<pre>*Mar 24 13:40:28.800: BGP: Regular scanner event timer
*Mar 24 13:40:28.800: BGP: Import timer expired. Walking from 1 to 1
*Mar 24 13:40:42.764: %TCP-6-BADAUTH: Invalid MD5 digest from 10.250.250.2(11064) to 84.22.96.5(179)
 </pre>
<p> <strong>Case 4 </strong><u>On Cisco ttl-security is enabled while on Forigate ebgp multi-hop is not .</u><br />
There is no such thing as TTL security on the Fortigate by the way, all you can do to handle this state is enable ebgp-multihop and them it starts sending BGP packets with ttl = 255 .</p>
<p>Cisco:</p>
<pre>Jan  7 13:01:36.992: %BGP-4-INCORRECT_TTL: Discarded message with TTL 2 from 10.250.250.2</pre>
<p> Forigate:</p>
<pre>
BGP: 84.22.96.5-Outgoing [FSM] State: OpenConfirm Event: 11
BGP: 84.22.96.5-Outgoing [ENCODE] Msg-Hdr: Type 4
BGP: 84.22.96.5-Outgoing [ENCODE] Keepalive: 13548 KAlive msg(s) sent
84.22.96.5-Outgoing [FSM] State: OpenConfirm Event: 10
BGP: 84.22.96.5-Outgoing [ENCODE] Msg-Hdr: Type 3
BGP: %BGP-3-NOTIFICATION: sending to 84.22.96.5 4/0 (Hold Timer Expired/Unspecified Error Subcode) 0 data-bytes
BGP: 84.22.96.5-Outgoing [FSM] State: Idle Event: 3
BGP: 84.22.96.5-Outgoing [NETWORK] FD=14, Sock Status: 111-Connection refused
BGP: 84.22.96.5-Outgoing [FSM] State: Connect Event: 18
</pre>
<p> <strong>Bonus Case </strong> Bug-not-a-feature thing on the Fortigate – when configuring MD5 password for  BGP authentication you get Cross-Site vulnerability protection for free <img src='http://yurisk.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   Don&#8217;t ask  me how XSS is connected to cli configuration of BGP …</p>
<div class="cmd"> set password  &lt;2AEARep&gt;</div>
<p><span class="cmdout">The string contains XSS vulnerability characters<br />
value parse error before &#8221;<br />
Command fail. Return code -173</span></p>
]]></content:encoded>
			<wfw:commentRss>http://yurisk.info/2010/03/26/fortigate-bgp-configure-and-debug/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Failed to connect to Fortiguard servers</title>
		<link>http://yurisk.info/2009/06/19/failed-to-connect-to-fortiguard-servers/</link>
		<comments>http://yurisk.info/2009/06/19/failed-to-connect-to-fortiguard-servers/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 13:44:49 +0000</pubDate>
		<dc:creator>Yuri</dc:creator>
				<category><![CDATA[Firewall]]></category>
		<category><![CDATA[Fortigate]]></category>

		<guid isPermaLink="false">http://yurisk.info/?p=176</guid>
		<description><![CDATA[Today encountered otherwise easy to diagnose misconfiguration only that Fortinet decided to &#8216;hide&#8217; this parameter deep enough so that it got on my nerves until I fixed it. NOTE : Fortiguard is subscription based service when your Fortigate unit periodically connects to the Fortinet servers (collectively named Fortiguard servers) to get info that enables advanced [...]]]></description>
			<content:encoded><![CDATA[<p>Today encountered otherwise easy to diagnose misconfiguration  only that Fortinet decided to &#8216;hide&#8217; this parameter deep enough  so that it got on my nerves until I fixed it.</p>
<blockquote><p>NOTE : Fortiguard is subscription based service when your Fortigate unit periodically<br />
connects to the Fortinet servers (collectively named Fortiguard servers) to get info that enables advanced<br />
feautures like filtering by category/rating.</p></blockquote>
<p>Problem &#8211; suddenly Fortigate of the client refused to do web/spamfiltering service while having valid contract subscription. Not a big deal as in System -&gt;  Maintenance -&gt; Fortiguard status was &#8220;Failed to connect &#8221; (or something of a kind dont recall it now) . On the same page there is a nice button &#8220;Test Availability&#8221;   pushing which would bring error &#8220;Connection failed Check firewall routing table&#8221; .<br />
In most of the cases it is either reachability issue or Fortigate is trying  to update against wrong server.<br />
Doing pings successfuly from the firewall to service.fortiguard.net  (FQDN to use for Fortiguard servers)<br />
left 2nd option  &#8211; wrong Fortiguard server hardcoded somewhere in the configs. Doing<br />
<strong>FG100 # show system fortiguard</strong>   Gave only this<br />
config system fortiguard<br />
    set antispam-cache disable<br />
    set webfilter-cache disable<br />
end</p>
<p>And only doing <strong>FG100 # get system fortiguard </strong>  Gave the answer<br />
hostname            : 66.92.33.1<br />
srv-ovrd            : disable<br />
port                : 53<br />
client-override-status: disable</p>
<p>To fix this you enter:<br />
<strong>FG100 # config  system fortiguard</strong><br />
<strong>FG100 (fortiguard) # set </strong><br />
*hostname                    hostname or IP of the FortiGuard server<br />
<strong>FG100 (fortiguard) # set  service.fortiguard.net</strong><br />
FG100 (fortiguard) #next</p>
<p>* FortiOS 3.x uses service.fortiguard.net , FortiOS 2.80 used  guard.fortinet.net  for Webfiltering and<br />
antispam.fortigate.com for Antispam filtering and it is Fortinet recommendation to do so, nevertheless<br />
setting guard.fortinet.net in Fortios 3 works as well (after all they are CNAME&#8217;d )</p>
<p>And while we are on it, here are few useful debug commands for the topic:</p>
<p> &#8211; To see real time list of servers to which the firewall tries to connect for Fortiguard service<br />
<strong>FG200# diagnose debug rating</strong><br />
Locale       : english<br />
License      : Contract<br />
Expiration   : Fri Jun 17 02:00:00 2010<br />
Hostname     : guard.fortinet.net</p>
<p>-=- Server List (Wed Jun 19 08:12:58 2009) -=-</p>
<p>IP                  Weight Round-time  TZ    Packets  Curr Lost Total Lost<br />
212.95.252.121           0         85   0     521863          0        113<br />
212.95.252.120           0         89   0       4625          0          5<br />
82.71.226.65             0         97   0       2140          0         34<br />
62.209.40.73            10        105   1       2060          0          0<br />
62.209.40.72            10        103   1       2060          0          0<br />
66.117.56.37            50        158  -5       2060          0          0<br />
69.20.236.180           50        191  -5       2060          0          0<br />
69.20.236.179           50        185  -5       2060          0          0<br />
66.117.56.42            50        164  -5       2061          0          1<br />
72.52.72.243            80        245  -8       2063          0          3<br />
116.58.208.39           80        371  -8       2081          0         21<br />
208.91.112.194          80        233  -8       2075          0         12<br />
216.156.209.26          80        239  -8       2068          0          7<br />
121.111.236.179         90        354   9       2061          0          1<br />
121.111.236.180         90        366   9       2064          0          4</p>
<p> &#8211; The same for Antispam service<br />
<strong>FG200# diagnose spamfilter fortishield servers</strong><br />
Locale       : english<br />
License      : Contract<br />
Expiration   :Fri Jun 17 02:00:00 2010<br />
Hostname     : guard.fortinet.net</p>
<p>-=- Server List (Wed Jun 19 08:13:39 2009) -=-</p>
<p>IP                  Weight Round-time  TZ    Packets  Curr Lost Total Lost<br />
212.95.252.121           0         94   0       2063          0          0<br />
212.95.252.120           0         96   0       2061          0          0<br />
82.71.226.65             0        104   0       2076          0         18<br />
62.209.40.73            10        113   1       2061          0          0<br />
62.209.40.72            10        111   1       2061          0          0<br />
66.117.56.37            50        159  -5       2061          0          0<br />
69.20.236.180           50        199  -5       2061          0          0<br />
69.20.236.179           50        193  -5       2061          0          0<br />
66.117.56.42            50        169  -5       2063          0          2<br />
72.52.72.243            80        273  -8       2065          0          4<br />
116.58.208.39           80        380  -8       2085          0         24<br />
208.91.112.194          80        271  -8       2071          0          8<br />
216.156.209.26          80        261  -8       2064          0          2<br />
121.111.236.179         90        362   9       2061          0          0<br />
121.111.236.180         90        370   9       2062          0          1</p>
<p> &#8211; To see on the console Webfiltering doing its work:<br />
<strong>FG200# diagnose debug application urlfilter 1</strong></p>
<p>FG200 # id=93000 pid=50 main-696 in main.c received pkt:count=197, a=/tmp/.thttp.socket/21<br />
id=22009 received a request /tmp/.thttp.socket, addr_len=21: d=www.cnn.com:80, url=/a7Admin/SelectImage.aspx?end=document.f.largeimage.value&amp;preview=document.getElementById(&#8216;oImg2&#8242;)&amp;w=319&amp;h=215, id=913659, vfid=0, type=0, client=192.168.7.238<br />
id=93000 msg=&#8221;found it in cache&#8221;<br />
id=93003 user=&#8221;N/A&#8221; src=192.168.7.238 sport=4796 dst=157.166.224.25 dport=80 service=http cat=36 cat_desc=&#8221;News and Media&#8221; hostname=www.cnn.com url=/a7Admin/SelectImage.aspx?end=document.f.largeimage.value&amp;preview=document.getElementById(&#8216;oImg2&#8242;)&amp;w=319&amp;h=215 status=passthrough msg=&#8221;URL belongs to an allowed category in the policy&#8221;<br />
id=93000 pid=50 main-696 in main.c received pkt:count=255, a=/tmp/.thttp.socket/21<br />
id=22009 received a request /tmp/.thttp.socket, addr_len=21: d=b.mail.google.com:80, url=/mail/channel/bind?VER=6&amp;it=460207&amp;at=xn3j2v04hx65iz3ypmmyzptrbkimsf&amp;RID=rpc&amp;SID=57A1C77D6AAC35B0&amp;CI=1&amp;AID=347&amp;TYPE=html&amp;zx=8i5clc-olem8j&amp;DOMAIN=mail.google.com&amp;t=1, id=900542, vfid=0, type=0, client=192.168.7.56<br />
id=93003 user=&#8221;N/A&#8221; src=192.168.7.56 sport=4280 dst=74.125.39.189 dport=80 service=http cat=23 cat_desc=&#8221;Web-based Email&#8221; hostname=b.mail.google.com url=/mail/channel/bind?VER=6&amp;it=460207&amp;at=xn3j2v04hx65iz3ypmmyzptrbkimsf&amp;RID=rpc&amp;SID=57A1C77D6AAC35B0&amp;CI=1&amp;AID=347&amp;TYPE=html&amp;zx=8i5clc-olem8j&amp;DOMAIN=mail.google.com&amp;t=1 status=passthrough msg=&#8221;URL belongs to an allowed category in the policy&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://yurisk.info/2009/06/19/failed-to-connect-to-fortiguard-servers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>You can&#039;t set duplex/speed settings of the Fortigate interfaces?</title>
		<link>http://yurisk.info/2009/06/10/you-cant-set-duplexspeed-settings-of-the-fortigate-interfaces/</link>
		<comments>http://yurisk.info/2009/06/10/you-cant-set-duplexspeed-settings-of-the-fortigate-interfaces/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 18:24:49 +0000</pubDate>
		<dc:creator>Yuri</dc:creator>
				<category><![CDATA[Firewall]]></category>
		<category><![CDATA[Fortigate]]></category>

		<guid isPermaLink="false">http://yurisk.info/?p=152</guid>
		<description><![CDATA[You can&#8217;t set duplex/speed settings of the Fortigate interfaces. Important FIX: depends on which interface you are trying to set! [ Thanks to Chen for pointing out ] Upon careful reexamination turns out that you can&#8217;t set duplex/speed settings of 4-port switch interfaces only, i.e. Internal interface of Fortigate 60, 60M, 100A, 200A, and FortiWiFi-60 [...]]]></description>
			<content:encoded><![CDATA[<p>You can&#8217;t set duplex/speed settings of the Fortigate interfaces.<br />
<strong> Important FIX: depends on which interface you are trying to set! </strong> [ Thanks to Chen for pointing out ]<br />
Upon careful reexamination turns out that you can&#8217;t set duplex/speed settings of <strong> 4-port switch interfaces only, </strong> i.e. Internal interface of Fortigate 60, 60M, 100A, 200A, and FortiWiFi-60 and also LAN interface of 500A . <br />
Tried on FG100A FortiOS v4.0,build0178,090820 (MR1) </p>
<div class="cmd">
FG100 (dmz2) # set speed<br />
100full    100M full-duplex<br />
100half    100M half-duplex<br />
10full     10M full-duplex<br />
10half     10M half-duplex<br />
auto       auto adjust speed</div>
<p>Working most of the time with Cisco gear I&#8217;m (and others) used to being able to set duplex/speed<br />
parameters on the physical interfaces to my liking.<br />
This comes as a necessity when connecting cisco to various equipment of differing quality. So it was a surprise to me when I encountered strange layer1/layer2 connectivity problem between some Fortigate 200A and cisco and tried to set manually duplex full/speed 100 on the Fortigate just to find out that it is impossible to do it on the Fortigate.<br />
It was possible back in the days of FortiOS 2.80 (and early 3.0 &#8211; I guess up until MR5)  :</p>
<p><strong># conf sys int</strong><br />
(interface)# edit internal<br />
(internal)# set speed</p>
<p>100full 100M full-duplex<br />
100half 100M half-duplex<br />
10full 10M full-duplex<br />
10half 10M half-duplex</p>
<p>But then Fortinet dropped this option and the only (not direct) explanation<br />
found on their site is this memo:<br />
&#8220;Locked-down port policies (forcing speed, duplex, and link capabilities with auto-negotiation disabled) are<br />
outdated. Legacy and historical reasons for forced setup with auto-negotiation disabled date<br />
back many years when the technology was new&#8230;&#8221;</p>
<p>Now we can  see what is the negotiated status of the links<br />
(this command also shows errors/collisions/MTU on the interface) :</p>
<p><strong>FG100 # diagnose hardware deviceinfo nic internal</strong><br />
Description VIA VT6102 Rhine-II<br />
Part_Number N/A<br />
Driver_Name via-rhine<br />
Driver_Version 1.1.17<br />
PCI_Vendor 0&#215;1106<br />
PCI_Device_ID 0&#215;3065<br />
PCI_Subsystem_Vendor 0&#215;3065<br />
PCI_Subsystem_ID 0&#215;1106<br />
PCI_Revision_ID 0&#215;74<br />
PCI_Address 0:12.0<br />
PCI_Bus_Type<br />
Memory 0x0000f400<br />
IRQ 11<br />
System_Device_Name internal<br />
Current_HWaddr 00:09:0f:30:32:11 #In HA set up primary member would have different , virtual MAC address , for more see here <a href="http://kc.fortinet.com/default.asp?SID=&amp;Lang=1&amp;id=1772">FortiOS v3.0 HA Cluster virtual MAC addresses </a><br />
Permanent_HWaddr 00:09:0f:30:32:11<br />
<strong>Link up </strong><br />
<strong>Speed 100 </strong><br />
<strong>Duplex forced full </strong><br />
FlowControl off<br />
State up(0&#215;00001103)<br />
MTU_Size 1392<br />
Rx_Packets 89944267<br />
Tx_Packets 73437299<br />
Rx_Bytes 370540924<br />
Tx_Bytes 428118992<br />
Rx_Errors 0<br />
Tx_Errors 0<br />
Rx_Dropped 0<br />
Tx_Dropped 0<br />
Multicast 8810<br />
Collisions 0<br />
Rx_Length_Errors 0<br />
Rx_Over_Errors -0<br />
Rx_CRC_Errors 0<br />
Rx_Frame_Errors 0<br />
Rx_FIFO_Errors 0<br />
Rx_Missed_Errors 0<br />
Tx_Aborted_Errors 0<br />
Tx_Carrier_Errors 0<br />
Tx_FIFO_Errors 0<br />
Tx_Heartbeat_Errors 0<br />
Tx_Window_Errors 0<br />
Tx_Single_Collision_Frames 0<br />
Tx_Multiple_Collision_Frames 0<br />
Rx_Frame_Too_Longs 0<br />
Rx_Symbol_Errors 0<br />
Rx_Control_Unknown_Opcodes 0<br />
Rx_Pause_Frames 0<br />
Tx_Pause_Frames 0<br />
Scatter_Gather OFF<br />
poll_intr_switch 0<br />
rx_tasklet_pkts 92505560<br />
xmit queue 0<br />
recv queue -64<br />
phy_id= 1/1</p>
]]></content:encoded>
			<wfw:commentRss>http://yurisk.info/2009/06/10/you-cant-set-duplexspeed-settings-of-the-fortigate-interfaces/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Debug VPN in Fortigate &#8211; seeing is believing</title>
		<link>http://yurisk.info/2009/04/21/debug-vpn-in-fortigate-seeing-is-believing/</link>
		<comments>http://yurisk.info/2009/04/21/debug-vpn-in-fortigate-seeing-is-believing/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 16:54:19 +0000</pubDate>
		<dc:creator>Yuri</dc:creator>
				<category><![CDATA[Firewall]]></category>
		<category><![CDATA[Fortigate]]></category>

		<guid isPermaLink="false">http://yurisk.info/?p=103</guid>
		<description><![CDATA[You can&#8217;t really debug VPN problems with static show commands, if VPN fails to function you HAVE to see it happening real-time. Below I list few debug commands that do just that for IPSEC site-to-site tunnels in Fortigate. Here: 192.168.168.254 &#8211; IP address on the LAN interface of the fortigate 10.170.15.131&#8242; &#8211; IP address on [...]]]></description>
			<content:encoded><![CDATA[<p>You can&#8217;t really debug VPN problems with static show commands, if VPN fails to function you HAVE to<br />
see it happening real-time. Below I list few debug commands that do just that for IPSEC site-to-site<br />
tunnels in Fortigate.<br />
Here:<br />
192.168.168.254   &#8211; IP address on the LAN interface of the fortigate<br />
10.170.15.131&#8242;    &#8211; IP address on the remote LAN<br />
200.199.20.162   &#8211; (sanitazed) IP of the wan interface of Fortigate<br />
72.21.207.65   &#8211;  (sanitazed) IP of the  remote VPN peer</p>
<p>-Enable debugging<br />
 <strong>FG100A# diag debug en</strong></p>
<p>- Enable debug messages for specific application , here we are interested in IKE (note debug level -1,<br />
following logic I enabled first +1, 255 etc and surprisingly had no effect at all )<br />
 <strong>FG100A # diag debug app ike -1</strong></p>
<p>I, personally, prefer also to do sniffer on the tests I  do after, so:<br />
<strong>FG100A # diagnose sniffer packet any &#8216;host 10.170.15.131&#8242;</strong></p>
<p>Now open another ssh session to the same FG and do pings to IP on the other side of VPN tunnel<br />
with source IP of internal LAN (or just ask client to do pings from LAN, depends on encryption domain) :</p>
<p>- Configure pings to go with the source interface of LAN of the Fortigate:<br />
<strong>FG100A # exec ping-options source 192.168.168.254</strong><br />
- No wdo pings to bring up the VPN tunnel<br />
<strong>FG100A # exec ping 10.170.15.131</strong><br />
PING 10.170.15.131 (10.170.15.131): 56 data bytes<br />
64 bytes from 10.170.15.131: icmp_seq=1 ttl=252 time=73.2 ms<br />
64 bytes from 10.170.15.131: icmp_seq=2 ttl=252 time=116.3 ms<br />
64 bytes from 10.170.15.131: icmp_seq=3 ttl=252 time=110.3 ms<br />
64 bytes from 10.170.15.131: icmp_seq=4 ttl=252 time=138.4 ms</p>
<p>Now return to the 1st ssh session and you will see:</p>
<p>interfaces=[any]<br />
filters=[host 10.170.15.131]<br />
0:Robophone1:Robophone1/2: IPsec SA connect 3 200.199.20.162-&gt;72.21.207.65:500  , natt_mode=0<br />
0:Robophone1: using existing connection, dpd_fail=0<br />
0:Robophone1: found phase2 Robophone1/2<br />
0:Robophone1: IPsec SA connect 3 200.199.20.162-&gt;72.21.207.65:500 negotiating<br />
0:Robophone1:1990: cookie d3351433913f978c/069bcd9a38263f3a:5125b9f3<br />
0:Robophone1:1990:Robophone1/2:471585: initiator selectors 0 200.199.20.162:0-&gt;10.170.15.131:0<br />
0:Robophone1:1990: sent IKE msg (quick_i1send): 200.199.20.162:500-&gt;72.21.207.65:500, len=148<br />
Robophone: Initiator: sent 72.21.207.65quick mode message #1 (OK)<br />
0: comes 72.21.207.65:500-&gt;200.199.20.162:500,ifindex=3&#8230;.<br />
0: exchange=Quick id=d3351433913f978c/069bcd9a38263f3a:5125b9f3 len=156<br />
0: found Robophone1 200.199.20.1623 -&gt; 72.21.207.65:500<br />
0:RobophoneRobophone1:1990:Robophone1/2:471585: responder selectors 0 200.199.20.162:0-&gt;10.170.15.131:0<br />
0:Robophone1:1990: sent IKE msg (quick_i2send): 200.199.20.162:500-&gt;72.21.207.65:500, len=60<br />
0:Robophone1:1990:Robophone1/2:471585: set sa life soft seconds=1775.<br />
0:Robophone1:1990:Robophone1/2:471585: set sa life hard seconds=1800.0:Robophone1:1990:Robophone1/2:471585: add SA #src=1 #dst=1<br />
0:Robophone1:1990:Robophone1/2:471585: src 0 4 192.168.168.0/255.255.255.0<br />
0:Robophone1:1990:Robophone1/2:471585: dst 0 1 10.170.15.131<br />
0:Robophone1:1990:Robophone1/2:471585: installed SA: SPIs=2f1c289f/ea7a510d<br />
0:Robophone1:1990:Robophone1/2:471585: sending SNMP tunnel UP trap<br />
Robophone1: Initiator: sent 72.21.207.65  quick mode message #2 (DONE)<br />
15.153033 10.170.15.131 -&gt; 200.199.20.162: icmp: echo reply<br />
16.196213 10.170.15.131 -&gt; 200.199.20.162: icmp: echo reply<br />
17.190216 10.170.15.131 -&gt; 200.199.20.162: icmp: echo reply<br />
18.218259 10.170.15.131 -&gt; 200.199.20.162: icmp: echo reply</p>
<p>4 packets received by filter<br />
0 packets dropped by kernel</p>
<p>Dont forget to disable debug afterwards</p>
<p><strong>FG100A # diag debug app ike 0</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://yurisk.info/2009/04/21/debug-vpn-in-fortigate-seeing-is-believing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Black hole routing to the rescue &#8211; Fortigate OS 4 surprise</title>
		<link>http://yurisk.info/2009/04/09/black-hole-routing-to-the-resque-fortigate-os-4-surprise/</link>
		<comments>http://yurisk.info/2009/04/09/black-hole-routing-to-the-resque-fortigate-os-4-surprise/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 10:59:25 +0000</pubDate>
		<dc:creator>Yuri</dc:creator>
				<category><![CDATA[Firewall]]></category>
		<category><![CDATA[Fortigate]]></category>

		<guid isPermaLink="false">http://yurisk.info/?p=98</guid>
		<description><![CDATA[Many times there is more than one solution to the problem, and the most obvious is not the best one. I reminded myself this when came to my care Fortigate 60 unit that was periodically blocking traffic, you know this not-saying-much system alert &#8220;..has reached connection limit&#8221; and then no traffic goes from LAN to [...]]]></description>
			<content:encoded><![CDATA[<p>Many times there is more than one solution to the problem, and the most obvious is not the best one. I<br />
reminded myself this when came to my care Fortigate 60 unit that was periodically blocking  traffic,<br />
 you know this not-saying-much system alert &#8220;..has reached connection limit&#8221; and then no traffic goes from LAN to WAN.<br />
Clearly being a resource starvation issue you may never know for sure what causes this , it may be<br />
oversized rulebase, custom IPS , AV set on everything and everywhere, etc.,.. The only way to pinpoint the<br />
misbehaving component is by elimination &#8211; disabling one by one until problem disappears. So for this<br />
particular Fortigate it was URL-filtering used to block access to Facebook.com. Unfortunately once this<br />
disabled users in LAN would cause starvation of the bandwidth by accessing (or rather not leaving) this<br />
website. An internal fair use policy issue ? &#8211; yes of course, but the only way to implement the policy<br />
was by force in this case. So if not URL-filtering (being the obvious solution) then black-hole routing would<br />
be the better one I thought &#8211; but in this FG OS 3 i didnt find such option, and as upgrade to Fortios 4 wasnt<br />
 an option I blackholed Facebook.com IP range (thanks to Facebook for the convenience of continuous IP<br />
range ) in the WAN facing Cisco router.</p>
<p>In the FortiOS 4 you can configure blackhole routing with no hassle:<br />
<code>FG100 # config router static<br />
FG100 (static) # edit 5<br />
FG100 (5) # set blackhole ?<br />
disable    disable setting<br />
enable     enable setting<br />
FG100 (5) # set blackhole enable<br />
FG100 (5) # set dst 69.63.176.0/20<br />
FG100 (5) # end<br />
</code><br />
Verify:<br />
<code>FG100 # show router static<br />
config router static<br />
    edit 1<br />
      ----output omitted----<br />
    edit 5<br />
        set blackhole enable<br />
        set dst 69.63.176.0 255.255.240.0<br />
    next<br />
end<br />
</code><br />
From station in LAN:<br />
<code># ping 69.63.184.142<br />
PING 69.63.184.142 (69.63.184.142) 56(84) bytes of data.<br />
From 10.99.99.254 icmp_seq=1 Destination Net Unreachable<br />
From 10.99.99.254 icmp_seq=2 Destination Net Unreachable<br />
</code><br />
Facebook IP range:<br />
 whois 69.63.176.140<br />
[Querying whois.arin.net]<br />
[whois.arin.net]<br />
OrgName:    Facebook, Inc.<br />
OrgID:      THEFA-3<br />
Address:    156 University Ave, 3rd floor<br />
City:       Palo Alto<br />
StateProv:  CA<br />
PostalCode: 94301<br />
Country:    US<br />
NetRange:   69.63.176.0 &#8211; 69.63.191.255<br />
CIDR:      <strong> 69.63.176.0/20</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://yurisk.info/2009/04/09/black-hole-routing-to-the-resque-fortigate-os-4-surprise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
