(DevCourseWeb - Com) FortigateFirewallAdminCrashCourse
(DevCourseWeb - Com) FortigateFirewallAdminCrashCourse
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
You will find different virtual machines images, choose your VM platform, I use
the VMware ESXi with my VMware fusion for Mac
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 your VM
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 setup should take a few minutes
Once you finish the setup, you will see your VM summary. Press the Finish
button, and your VM will start to load and Booting the Kernel
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
Now open up your browser, using the address you have configured, and enter
the credentials you have set up at the beginning ( admin, password )
Physical appliance
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
Let's Start
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 look at the different capabilities, using screenshots from my home
FortiGate but let’s start with the basic things you do when you connect through
the administrative interface and that is:
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.
Once you are connected to your FortiGate for the first time ( On one of the
available ports ), you are actually the Administrator of the machine. you have all
the ROOT privileges and you can do just about anything from assigning new
administrators or configuring your FortiGate firewall without any limitations
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
Configuring an Admin Account
You are the Admin of your Firewall, similar to ROOT in a Linux Machine
Configuring an admin profile is probably one of the first things that you will do
with your FortiGate.
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.
It has different Read/Write permissions, which we as Super admin can
determine.
So let's create a new professional admin profile. Let's log out and enter again as
the new professional admin and see the differences.
Once configured, let's move over to the admin menu which is on the top right
side of the interface, and log out.
And let's log in again as the new professional admin I am using the “ofershm”
username and the new password that we have just created.
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.
Super Admin Account
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.
For the purpose of our demonstration, we will use my second admin account
which is “test”, it is a professional admin account. Now if I'll try to edit it using the
GUI, we will see that indeed, two-factor authentication, we only have two
possibilities. The first one is FortiToken and the second one is the FortiToken
Cloud.
To get our third option, which is the email, we should open our command line and
type “config system admin”
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
rangehello@gmail.com
Now if we will refresh the page, we will see that we have a third option
Configuration Backup
Backing up your configuration should become second nature. You can
backup your configuration to a TFTP server, to your local disk, or to a USB
drive
Let’s start by looking at our current configuration using the CLI
“Show full-configuration”
This command will list all the configurations that are currently on your FortiGate,
including interfaces, policies, protocols, services, passwords, accounts …
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
A good practice is to save revisions of your backup with descriptions for each, so
you will know what has changed
On the admin menu configurations --- revisions - save changes
Automatic Backup on LogOut
One of the coolest features you can use is to automatically backup your
configuration on every log-out.
Our trigger will be “schedule”, we will set a daily hour, in which a backup will
happen automatically, using a CLI Script
So let’s move to security fabric--automation
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 Idea Behind Automation Is That You Can Do A Bunch Of Things Using
The Automation Scripts That Will Help You To Offload Daily Tasks
------------------------------------------------------------------------------------------------------------
Configuring a new LAN interface
You can configure your LAN interface using the graphical user interface,
which is quite intuitive, or using the CLI as we did at the beginning, so here
is a reminder and let’s start from the basics
The second thing to do is set the protocols allowed to access that interface. you
do that using the “set allowaccess”
This is the basic setup, but you can add up more information, actually a lot more
information as seen in the screenshot
Configuring interfaces is one of those things that determines and changes your
topology and network capabilities completely. If you want to see which
capabilities and support can be added, just type :
“config system interface”
“edit port (X)”
“show full-configuration “
Configuring Interface Using the GUI
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 …
--------------------------------------------------------------------------------------------------------
Note — there are tons of things that you configure on your interface, but we
will focus on the most basic and fundamental
---------------------------------------------------------------------------------------------------------
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
If you enable the advanced options, you will have more options, as using a
DHCP relay, that is if you don’t want to use your interface DHCP server, you can
also configure, additional DHCP options, known as scopes ( as in the case,
where you will want to send your wireless clients the IP address of their a Wi-Fi
controller, change the Lease time or send an NTP server address )
DHCP configuration also includes the ability to assign or reserve IP addresses
to specific MAC address, or to block MAC addresses from getting IP addresses
●
Following our Basic DHCP server Configuration, we can enable several more
features, one of them is device detection ( very useful when you have different
types of devices and operating systems in your network ) and enable a captive
portal authentication for the employees or a specific group of employees ( good
for outsourcing employees )
Captive Portal
Captive Portals are a common security procedure, used consistently on our
networks for guests or even when outsource employees work within your
internal LAN, connecting through ethernet wall sockets.
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
On your FortiGate admin page, choose network —interfaces
The opened screen will list all Interfaces on your Fortigate firewall, we will choose
to apply our captive portal to our Marketing LAN, but you can choose to do it, on
any LAN you wish
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
The New Page that will be opened will allow you to create new interfaces (
Software switch, Loopback, SSID…) we will focus on our VLAN Interface,
which will allow us to create another broadcast domain running on our physical
port 2
Now, Let’s configure our new VLAN
● Name: outsource
● Alias: let’s give it the same number as our Vlan ID which will be 100
● Type: we will choose Vlan out of all choices
● Interface: here we choose the physical interface that will occupy our
VLAN, in our case it is Marketing port 2
● VLAN ID: that’s the 802.1q tagging of our VLAN as seen by the switch
● Role: we will choose LAN, as it will be used as a local area network for our
outsource employees
------------------------------------------------------------------------------------------------------------
REMEMBER our VLAN, is another Local area network of itself
------------------------------------------------------------------------------------------------------------
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
Let’s click OK for now, we will get back to our VLAN interface again.
On the interface page, you will see the + sign next to our marketing interface
Click on the + sign, and you will see our new outsource VLAN 100 at the
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
Coose Local User and click Next
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
You can also exempt sources, that you do not want to be directed to the captive
portal page. you will need to create a firewall address object, as shown in the
next chapter
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
And now if we move back to our interfaces page , we can see that we have a
new VLAN interface
Our new VLAN behaves just like any other local area network, you can keep on
configuring DHCP services, DNS services, just about anything on that VLAN the
same way as you were doing on any other interface.
Creating firewall Address Objects
Your firewall rules will require you to recognize specific devices in your
LAN, using IP address, Geographic location ( in the case that we will want
to block geo- address as destinations ) and more.
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
From here we will type the following
● We have created a new object using the “ config firewall address “
command
● Named it “NAS” with “edit NAS”
● Associate it with the relevant interface ( port 10 ) - “set
associated-interface port10”
● And assigned an IP address - “set subnet 10.0.7.11 255.255.255.255”
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
But this time let’s configure another type of address object, the GEO location
object. fill in the name, type of object, country, and interface
Click OK, you can see the address object in the list of addresses
Summary
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
Layer 3 Routing
Routing is a destination decision making in other words, it is the thing that
controls how packets are sent along the path from source to destination.
Routing is an OSI layer 3 decision, and network devices that belong to that
class are known as Routers. Your FortiGate firewall is not only a
next-generation firewall, but it is also a router
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.
Policy-Based Routes
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
the Active Routes. It gets them from the routing table. It also holds routes that
are routes that are dedicated to SSL VPN or IPsec. How do you get to see the
fib?
And that's the FIB, the third database that your FortiGate checks before it sends
the packet towards its destination.
Static Route
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
We need to tell our FortiGate...
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
Static routes ( as dynamic routes ) have different attributes that determine if
they are Active or Not, Preferred more or Less. static route attributes are
Distance and Priority ( available in the advanced options ), we will not get to
this, in this book, so keep the administrative distance to 10, that is the default
setting
So, we have a default route that sends packets to our WAN i nterface, towards
our ISP router.
Set Up Policies
Alright, we have our interface all set up, our firewall address object and now we
also have a static route, that will let packet flow towards the ISP router on their
way to the internet
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.
So when we start to configure our firewall rule, we have, an implicit deny rule at
the bottom. And from there, we start to configure our different criteria that will be
matched against your traffic.
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
We have said that a policy checks for traffic matching
so let's fill in the missing details
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
Demystify Sessions
Your Fortigate is a session aware firewall, it looks at the first packet that is
sent by the source, saves it’s routing information, then waits for the
responding packet, and only then it creates a session in the session table.
Each session has time to live interval, route information, different states,
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 from here you can see all the different hosts in your networks and their
different sessions. Now, if you want to be more granular, you can just use the
grep command.
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”
As you can see, we have dozens of sessions that are happening just now.
So we will have to use a filter.
Our filter will be the source address which is the 10.0.5.7
“Diag sys session filter src 10.0.5.7”
“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
You can use the grep command again, to filter and be more granular on the
different items that you seek such as the type of protocol. Now it's using protocol
6, which is TCP but there are many details on the session output that needs to
be clarified
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
Each line in the logs represents a session
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
In the session state, we see that it is equal to log, which means, that the session
is being logged
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
Following the state, you will find the expiration time, the duration of that session,
these are self-explanatory
If you are using a traffic shaping policy, then you will notice that on the origin
shaper fields
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”
Let's set the TCP port range to be 443 only 443.
And let's set the session Time To Live to never.
Now let's end it
And you can also see the new service under the Services tab and categorized
services that we have just created.
Log And Report
Logs are fundamental to your FortiGate Administration. Let's look at the
log structure and understand how that works.
You can look at the different logs using the graphical user interface in the
log and report menu.
From there, you will see the different logs as forward traffic logs which track,
traffic that flows between your FortiGate interfaces
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
Let's look at the structure of the log. The log is actually comprised of two parts:
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.
Log settings
Another good command that you will probably use is the
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
Delete Logs
The last command is the
“execute log delete-all “
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.
-----------------------------------------------------------------------------------------------------------
Useful CLI Commands
The following commands are helpful to monitor and diagnose your fortigate
firewall
“execute ping-options”
Troubleshoot connectivity using ICMP packets. This command has different
options as count, interval, source, and more
“Show system interface port(x)”
Shows the current configuration on different interfaces
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