Fortigate@nettrain
Fortigate@nettrain
It does not cover every topic, only those that are needed for
you to get around quickly and administrate your firewall in
different topologies and use cases
Everything in this book is done on a virtual machine, which you can download at
https://support.fortinet.com/
Here you will create a free account, once you set up your account, navigate to
the Download section at the top bar and click on VM Images
Make sure that you download the correct image ( new deployment ) . the current
version, at the time this book was written, is 6.4.4
The free version that you will download has some limitations, but it will do for
most of our practices
Importing the image to your VM platform and configuring your FortiGate depends
on your OS of choice, we will do it using My Macbook, but the flow is very similar
in windows
Go to File --- Import and choose your Fortigate VM that you have just
downloaded. The download is usually in ZIP, so you will have to extract it
The IP address that you have just configured is a static one, make sure that it is
in your home/office subnet , the one that you are connected to
The “set allowaccess” actually defines the protocols that you are allowed to
connect through as an admin
You will need to connect your computer to that port. you can also configure your
computer in the 192.168.1.0 subnet range ( configure it with a static IP address in
that range if it doesn’t get for some reason an IP address from port1 interface )
All of the things that you will learn in this book applies to both Virtual and
physical devices
You can do a lot with your NGFW firewall, from Simple Rules, Web filtering,
Deep SSL inspection of the traffic, IPsec tunnels, custom IPS signatures, even
using it as a web application firewall. This book will focus on most used
administration topics, as well as firewall rules, routing and analyzing sessions
We will configure the above using the Graphical user interface, but we will focus
on the Command Line, which is the best way to get into the advanced stuff.
On your Left menu pane c lick system--- administrators, choose admin and
edit you can configure your admin profile ( password and name), 2-factor
authentication, trusted hosts ( IP addresses ) that you can connect from, and
more
You can set up your admin profile using the graphical user interface, and you will
probably do so once you get into your FortiGate. But this time, we'll do it using
the command line.
Looking at the different admin profiles, we can see that there are two main
profiles.
The first profile is the super admin, which actually has permissions to just about
anything, it has the Read/Write permissions to any place in the FortiGate
interface. The second profile is the professional admin. which is usually a
limited admin.
Once configured, let's move over to the admin menu which is on the top right
side of the interface, and log out.
Alright, it looks similar. But when we will move between the different menus. We
will see that as a professional admin ( which has only the read permissions )
we cannot do anything. We can only view the current configuration. We cannot
create or edit new interfaces or policies.
uper admin
Now let’s create another admin, this time a s
The next thing to do is to name our admin, let's name it test admin. We do that
using the edit command
“edit test”
Now let's set a password for that admin, let's set a simple password ( don't use
that in real environments ). And let's set a trusted host. a trusted host is a place
from where the admin will connect to our FortiGate. A good practice is to set up a
trusted host from within the subnets, or the IP address in our home in our
admin’s home, or from the work.
Alright, so now we have configured one trusted host, we can configure several
trusted hosts.
So this is the basic, the most basic admin profile configuration. Let's end it.
And let's see it using our graphical user interface.
The next thing is something that is quite interesting. Now, you're a privileged
admin. You're a super admin, and you have professional admins that administer
different tasks in your FortiGate.
You can set up different things based on the fact that you're the privileged admin,
such as password expiry for those professional admins.
Now you will add the profile that you wish to add the email two-factor
authentication In my case, it's “test”
You will set the two-factor email which enables you to have The third option on
the GUI itself and you can set the email to where to send the token itself.
Let's set it to o
[email protected]
Now if we will refresh the page, we will see that we have a third option
“Show full-configuration”
To backup, your configuration, navigate to the top right page of your FortiGate
admin page, where and click on the admin menu
The menu will show up with several options ( logout, change password,
configuration )
-------------------------------------------------------------------------------------------------------
NOTE: EVEN IF YOU DECIDED TO KEEP THE CONFIGURATION WITH NO
ENCRYPTION, YOUR PASSWORDS ( ADMIN PASSWORD, USER
PASSWORDS, WILL STILL BE HASHED, SO NO ONE CAN USE THEM )
--------------------------------------------------------------------------------------------------------
You can restore the configuration backup, to other FortiGate machines, but
it depends
● If the back up wasn’t encrypted, you will need a similar FortiGate model
● If the backup was encrypted, you will need the password, similar model,
and similar firmware
Our trigger will be “schedule”, we will set a daily hour, in which a backup will
happen automatically, using a CLI Script
Our CLI script will be "execute backup config tftp back.conf 10.0.7.22"
● Back.conf = the name of the file
● 10.0.7.22 = the IP address of the TFTP server
The second thing to do is set the protocols allowed to access that interface. you
do that using the “set allowaccess”
At the address field, choose your LAN gateway IP address, you can choose to
get one from a DHCP server, but will set it in a static ( manual ) way
From here, you can configure the administrative access that will allow you to
connect to that interface, either HTTPS, SSH …
Your LAN will lease IP addresses to all members of the subnet, so we will set a
DHCP server, by enabling it
DHCP service
You can control the number of IP addresses, bare in mind, that you don’t
necessarily need to have 254 addresses available, if your LAN has only 15
employees, use 30 or 40 addresses
In our current topology, We will not use LDAP For our outsource group ( although
it better to do so and more reasonable, but let’s make things simpler ) we will use
our local FortiGate firewall database
Our Topology
Quite a simple Topology, SMB switch connected to our Marketing LAN, and a
FortiGate that is connected to the ISP router
Our Marketing LAN has Connected to Port 2 and the subnet is 10.0.5.0/24
Employees on that LAN are connected through the switch which is connected To
the Fortigate Firewall, Currently with No VLAN”s
VLAN Creation
Let’s create the VLAN that will be used to connect our outsource employees to
the network
You can create VLANs using the GUI, the graphical user interface by moving to
create a new interface, and VLAN.
So move to the create a new interface, on our network interface page, and
Choose an interface
Now let’s assign a new IP address at the 10.0.7.0 subnet, a DHCP service, so
our employees will lease IP’s and administrative access for the admin using
HTTPS and SSH
10.0.7.1
User Group
Now let’s create a group for our outsource employees, as said, we will not use
LDAP or any other remote authentication servers, we will use our local firewall
database
Here you will create your outsource employees, let's create two employees
Click New
Choose a Username and Password, that will be used when your employees,
will authenticate, through the captive portal
Click Next, you will have the option to add an email and two-factor authentication
Name your group and click on the Members + sign, here you will add the new
users that you created
Scroll down to the network part, where you will see the Security mode button,
Now let's choose our user group, click on the + sign next to User groups and
choose the group, that you have just created
Press OK. that’s it, you have created your first captive portal
You will need to make sure, that your switch supports Vlan’s, and to assign the
relevant VLAN100 on that switch also, besides that, you’re done, your FortiGate
port2, has become a Trunk port, that can except native VLAN traffic, and your
outsource VLAN 100 traffic
We can also create Vlan’s Using the CLI, so let’s do that to our marketing
interface at the 10.0.5.0/24 subnet, assuming that we need another broadcast
domain for outsource employees
Our VLAN ID will be 100, and it will be associated with port 2, which is our
Marketing Port and it’s IP address will be 10.0.2.1
To configure our address object in our LAN, we will use the command line,
remember that:
● Our NAS belongs to the 10.0.7.0/24 subnet
● It is connected through port 10
● It has the 10.0.7.11 address
To get into the command line, click again on the CLI symbol at the top right side
of the page which will open the command line
Now we can use our address object in different policy scenarios to block or allow
this specific object.
We can also create address objects using the GUI. just navigate to Policy &
Objects --- Addresses
Click OK, you can see the address object in the list of addresses
We needed to create a firewall address object so that we could, later on, point
specifically to that device on our subnet
Now it is time to let traffic from our interface get out to the internet with the
static route and our first policy
Network devices that perform routing, contain a Routing Table, which helps
them to specify the next hop for a packet, using rules. your FortiGate does
routing lookups every time it needs to route packets
Routing Decisions
When it receives the second packet, the one that came from the destination
towards the client, it saves the route lookup, it does another route lookup, it
saves it into the session table.
You will see the connected routes, you see the static routes, dynamic routes,
such as OSPF or RIP, any route that is an active route
You see every route that there is in the routing table, including routes that are not
Active, as the route to 10.0.7.13.
One thing that you're not seeing on the routing table is the Policy-Based routes.
If you move to network policy routes, you can actually create routes that are
much more granular in terms of the protocol that is being used, the source
address that is being used, and so on.
The Policy-Based Routes are actually the first place that your FortiGate checks
to see if there's a route towards the destination that is in the policy-based route. If
it doesn't find a match, the second place that it goes to is the routing cache.
Routing Cache
The Routing Cache is actually a mechanism that deals with performance. you
want to route as fast as possible. And your FortiGate has a dedicated memory to
cache entries, that is, the routing cash, how can you see the routing cache?
FIB
The third-place that your FortiGate checks for routes, if it doesn't actually find
anything in the routing cache, or in the policy-based routes is the FIB. The
Forwarding Information Base holds the active routes, not every route, but only
And that's the FIB, the third database that your FortiGate checks before it sends
the packet towards its destination.
So in our topology, we have the LAN which is at the 10.0.7.0/24 subnet, we also
have our WAN interface which is connected to our router at the 10.0.3.55
A default Route is the same route that you are getting whenever you connect in
your home to your ISP router. which means that any packet that does not have a
specific route in your routing table, will be forwarded to the default route ( your
router ISP ) as the default Hop
And in static route create a new static route, the following screen will appear
So, we have a default route that sends packets to our WAN i nterface, towards
our ISP router.
You should think of policy as “Traffic matching”, that is, you define a rule that
will allow or deny traffic, assuming that it finds a match, once it finds a match (
that is your policy ), that are a set of things, it can do with that traffic, allow or
deny it, save logs, do a network address translation, apply a security policy and
more
There are different types of policies in your FortiGate, we will look at the
A firewall policy is nothing more than a set of criteria that your traffic needs to
match. Whenever an IP session happens in your network, a set of rules are
being matched against that traffic. If your firewall doesn't find a match at the first
rule, then it goes to the next rule, rules are handled from top to bottom. Now let's
look at how our policy rule is being configured and what objects are used to
create that match.
In every policy, there's always the implicit deny rule that sits beneath every other
rule. That is if your firewall doesn't find any match in the traffic, then the traffic
goes to the implicit deny rule, and it is being dropped.
The second match is the incoming interface. What is the incoming interface?
Well, for example, that could be the interface that your local area network is
connected to. Wherever the traffic comes from. it could also be your WAN
interface
If you're configuring a full access policy that will allow anyone to get out to the
internet, then it will probably be “ALL” in the destination field
if you're configuring a specific destination, then be sure to configure them ahead
and use them in your policy.
This was actually the first part of your policy or rule creation.
Once you have a match, your FortiGate will move to your security profiles, which
is going through antivirus application control, IPS, and so on.
The other thing that you will have to take care of is are you using network
address translation? Are you logging all sessions or only security events?
Navigate to Policies and Objects ( you probably guessed it :-), on your left
Pane
Create a new Policy, and you will see the following screen
You will see that underneath the matching fields, you can set more settings such
as the inspection type ( Flow or Proxy ), NAT, Security Profiles, Logging, and
more
Tracking Sessions
The following is a very typical scenario, you have a host, which is part of your
local area network. And you want to track its sessions, the places that your host
connects to. Now, you can do it in multiple ways you can look at the log report,
you can look at the FortiView. But let's do it using the CLI coming up.
So here's the following scenario, you have a device that is part of the 10.0.5.0
subnet. Its IP address is 10.0.5.7 And we want to track its sessions. Now, as I
said, we can do it in different ways
So the first command that you can use is the “get sys session list”
And here we can see different sessions that are happening, one of them as you
can see is talking through UDP towards google’s DNS server.
Now the other way to do it is using the “diag sys session list”
We can filter protocols, destinations, and much more, play around with that,
filtering is a powerful tool
And there we get sessions that are used only by our device
Session Vocabulary
When you look at a session output, the first reaction “WOW”, what’s that, so let’s
try to analyze the most important ones, and doing so, just look at your session
output
You can view your sessions, in different places, one of them is the logs, as long
as you enable logs for all sessions on the policy page
When you move to Log and report --- Forward Traffic, you can see all the
traffic that moves between your FortiGate interfaces
Click on any details and on the top right side, click on “details”
You will see the matching session ID
We can see in the button the total number of sessions related to this policy
Session proto
It is the protocol used, it has a numbering index where:
● 6=TCP
● 17=UDP
● 1=ICMP
You can find the full list using google, but these are probably the main ones that
you will meet
Session State
Following the protocol that is used, comes the protocol state. Again there is a
numbering index, but before that, think of a regular 3 way TCP handshake
A client sends a SYN packet, The server responds with a SYN/ACK the client
returns an ACK. When it wants to finish the connection, it sends a FIN packet,
and so on
May Dirty
The next interesting part is the state where it shows up = may dirty. there could
be 2 states, either dirty or may dirty
Session TTL
When a user doesn't perform any action throughout a session, this session
will time out.
Each session and its protocol has a different interval on your FortiGate firewall.
A TCP session by default will timeout after 3600 seconds. But there are cases
such as in the medical world where you need your services, your sessions, not to
time out. How do you do it using a policy? And how do you do with using a
custom service?
We can take a look at sessions that are TCP sessions, we can see that we have
an expiration time of 3600 seconds. Now let's configure a custom service
Using the “config firewall service custom”
You can look at the different logs using the graphical user interface in the
log and report menu.
Local traffic, which is internal traffic, sniffer traffic, if you're using packet capture,
and from there, you can see the different security profile logs.
To see logs either security logs or every session log, you have to enable logs in
your policy.
And if we click one of the logs, we can see that we have much more details,
either in terms of the action that the policy took or the application that was used,
we can also see the security level that was used.
Now, you do not have to use just about any security level out there. So let's
move to our command line
Getting back to our GUI logs. if we will click on the download logs ( the second
button from the left )
We can actually open the different logs once downloaded, let's just pick up one
log event
header part
The header part is similar in all logs, the body part is different
In the header, we can see the date, the log ID, the type of traffic, the subtype,
which is forward traffic, the severity level, which is only “notice”, and the Vdom
that we are working on which currently is the root Vdom
We will also see the action that was done. For example, if you see “client rst”,
it means that the server sent a TCP reset message to the client.
Now here you can set different settings that are related to your logs. One of them
is the maximum log age, which currently by default is seven days and you can
change it. It all depends on your hard disk and its storage.
Play around with the different settings, understand your logs capabilities, it’s
crucial to your everyday administration
You can delete all of your logs. Once done we don't have any more logs. Now
use it carefully.
----------------------------------------------------------------------------------------------------------
Don't just delete your logs; they are crucial to your organization’s
Security and Stability.
-----------------------------------------------------------------------------------------------------------
“execute ping-options”
Troubleshoot connectivity using ICMP packets. This command has different
options as count, interval, source, and more
But this was just the beginning. Your Fortigate firewall has so many areas that
we have not touched upon as Vdom’s, Proxies, security profiles, inspection
modes, clustering, and much more
“Fortigate Security crash course” is in the work and soon be published
Sincerely yours
Ofer Shmueli