Showing posts sorted by date for query diag debug flow. Sort by relevance Show all posts
Showing posts sorted by date for query diag debug flow. Sort by relevance Show all posts

Wednesday, April 29, 2020

Strongswan to Forticlient with RSA signature

In this post we will look at a simple lan2lan  VPN/ipsec using strongswan and  a fortigate.  Both devices are using RSA-signatures  for authentication.



So a certificate request was issued. I used getacrt for both gateways. The CN for the FortiGate  is "fgt.socpuppets.com" and the CN for the strongswan  is "strongswan".


Let's do the strongswan side. 1st you will need the certificate and key. Save these as two separate files with the extension pem. You have to copy these files into ./ipsec.d/certs and ./ipsec.d/private directories.


You will also need the root-cacert from getacrt , & copy to  it ./ipsec.d/cacerts

e.g




Now you can build a connection profile in ipsec.conf. In my setup I used the following;





use the %any for the rightid to ascertain the correct string if you have problems or see in your /var/log/daemon.log constraint errors. I will explain more later.








Once you have the ipsec.conf configured, you need to touch up ipsec.secrets. The entry is typically set in the following method & format

: RSA <certificate_name.pem>





if you get "can't find private key" in your logs is either one of the following 1> ipsec.conf has a typo  2> the reference ./ipsec/private/ directory is missing the file 3> the filename is incorrect 4> or the structure of : RSA <filename.pem> is bad



This concludes the strongswan side of the configuration.


On the fortigate it's pretty much straight forward as in route-based vpn thats for a dynamic-peer.

1st we define a user peer for identifying the remote gateway, calling up the CA and CN values



2nd phase1 config



3rd phase2 config


4th route



And finally firewall-policy



Okay, that concludes the configuration. On the FortiGate I had already created a CSR and import the signed certificate from getacrt, your certificate would typically be signed by your privateCA or public-CA that signs your CSR.

e.g  https://getacert.com/

Now let's look at some diagnostic and show. On strongswan you will use primary the following for review and troubleshooting

ipsec status
ipsec listcerts
ipsec statusall
cat /var/log/daemon.log
tcpdump -nnnnvv -i <interface public facing> host y.y,y.y
# y.y.y.y == right gateway ipv4 address

On fortiOS

diag debug flow
diag debug application ike -1
diag sniffer packet <interface public facing> "host x.x.x.x"
# x.x.x.x =  strongswan device ipv4
diag vpn ike gateway
diag vpn tunnel list


So in my strongswan, I run the ipsec up  command to start my ipsec connection attempt, since we have this connection set as "add" in the ipsec.conf

I've laid both a fortios & strongsan ipsec details next to each other , see the matching SPIs ?




For fortiOS phase1-details we use the "diag vpn ike gateway" command




For some more diagnostic tips

> ensure you have a policy with the action accept on the fortigate or you will get no policy found errors in diag debug application ike 

>  you monitor the loaded plugins in strongswan and for any errors during startup or tunnel up commands


> If your running iptables or a local host firewall, ensure you allow for both isakmp and esp.

> If you are getting constraint errors check the remote-identity string or use t he temporary use of %any to isolate the issue and to obtain the correct string. The order and items in the string is critical in your ipsec.conf file. Always check for errors or typos.

examples

 CN=fgt.socpuppets.com is not the same as CN=fgt

'C=US, ST=TX, L=AUSTIN, O=socpuppets, CN=fgt.socpuppets.com' is not the same as 'ST=TX, L=AUSTIN, O=socpuppets, CN=fgt.socpuppets.com'

> if your certificate-date has expired the vpn will not establish 


Almost all problems can be tracked down to incorrect named files or typos in the strongswan configurations from my personal experience & observations.


I've been working with strongswan for almost 13 years , btw. It's simple to deploy and use with linux based firewalls. You can build linux-based firewall and run strongswanfor remote-vpn with little to very little money invested. OPEX cost is very low and versus the performance potential

A design topology and a hub-DC mixed with a commercial FW.




Enjoy









NSE ( network security expert) and Route/Switching Engineer
kfelix  -----a----t---- socpuppets ---dot---com
     ^      ^
=(  @  @ )=
         o

        /  \



Tuesday, April 28, 2020

SSLVPN fortigate with certificates

In this post, I will demonstrate how to use and enable sslvpn with end-user certificates. The remote firewall is running 6.2.3 and we are using the 6.2 vpn client




I'm using firefox to test the web-portal and an android & macosx device running the basic forticlient

In the fortigate you should set a "config user peer" and define the CA that's signing the end-user certificates. This cert along with the rootCA certificate needs to be uploaded into the fortigate via the

System > certificate


In my setup, I have a root and intermediate CA. The "config user peer" is using my intermediate CA for the config.

config user peer
    edit "socpuppets-intermediate"
        set ca "CA_Cert_3"
    next
end

Now you will need to build your sslvpn settings to include an authentication-rule.

config vpn ssl settings
    set reqclientcert enable
    set ssl-min-proto-ver tls1-1
    set servercert "Fortinet_Factory"
    set tunnel-ip-pools "SSLVPN_POOL_1"
    set port 8443
    set source-interface "wan1"
    set source-address "all"
    set source-address6 "all"
    set default-portal "full-access"
    config authentication-rule
        edit 1
            set source-interface "wan1"
            set source-address "all"
            set groups "vpnusers1"
            set portal "full-access"
            set client-cert enable
            set user-peer "socpuppets-intermediate"
        next
    end
end


And the portal cfg with address pool

config firewall address
    edit "SSLVPN_POOL_1"
        set subnet 10.199.199.0 255.255.255.0
    next
end



config vpn ssl web portal
    edit "full-access"
        set tunnel-mode enable
        set ipv6-tunnel-mode enable
        set web-mode enable
        set ip-pools "SSLVPN_POOL_1"
        set ipv6-pools "SSLVPN_TUNNEL_IPv6_ADDR1"
    next
end


So no when a end-user authenticates and matches that auth-rule, he will need a valid certificate that matches the use-peer

Once you have connected you can validate users via the cli or webUi





















if your forticlient can not connect, use firefox and access the webportal , import the certificate that's being used by the forticlient. If you can access the webportal, than the certificate and authentication rule is good.









One last tidbit, when the user certificate has expired the user will be locked out of the vpn. Since the certificate verification is done before the acceptance of the "username/password" you will not see this in the logs but "diag debug application sslvpnd -1" will clearly show this scenario







For traffic that's allowed by the firewall policy you can use 

diag debug flow or run a diag packet sniffer on ssl.root interface to see the traffic flow






This vpn method offers a means to easily control vpn-users for a timed-access-control by signing the certificate for "X"  amount of days. Great for vendors, auditors, or consultant access.




NSE ( network security expert) and Route/Switching Engineer
kfelix  -----a----t---- socpuppets ---dot---com
     ^      ^
=(  @  @ )=
         o

        /  \


Monday, April 11, 2016

HOWTO: to determine in a ACT-ACT Fortigate HA cluster which unit is handing traffic

HERE's a few tips/tricks on  locating the ACT fortigate in a HA ACT vcluster1 & 2  setup where you have  vdoms  over clustered units



First you have to use the  ha management command ( similar to switch context  in  a cisco ASA )

e.g

execute ha manage <id#>

1:  You can  use the cli diag debug flow command

2:or the cli cmd  diag system session list  ( which filters if you have a lot of traffic ) will reflect  if that unit is active

and lastly,

3: And with any  remote logging ,  the devname=YYYYYYY and devid=XXXXXXX will be populated of the fortigate unit chassis  that handle that particular session.

Ken
NSE ( network security expert) and Route/Switching Engineer
kfelix  -----a----t---- socpuppets ---dot---com

     ^      ^
=(  @  @ )=
         o 
        /  \


Thursday, January 7, 2016

FortiOS diag debug flow filters

Here's some very strange behavior with the diag debug flow. I was playing around look at  incorrect network numbers and want to see if I could try some  weird addr filters with the diag debug flow

Check this out;


You can't specify a loopback   net127 but you can specify a improper  ipv4 address and a broadcast address.





So how about ipv6? Will let's find out.


Ken Felix
NSE ( network security expert) and Route/Switching Engineer
kfelix  -----a----t---- socpuppets ---dot---com

     ^      ^
=(  @  @ )=
         o 
        /  \


Wednesday, December 9, 2015

fortigate IPS diagnostics via cli commands

One of the cool things about the Fortigate IPS,  it's simple to run diagnostics. I will show you some tips & know transfers.


One of the first issues you need to know,  is to see what sessions are handled by ips. The cli cmd "diag ips session list" will list all sessions handled by the ips-engine. This gives you and ideal of what's being handle and inspected by any ips rule.

e.g ( here's a custom ips rule in a ips sensor for ftp for example  )






The cli cmds "diag ips session performance" "diag ips signature status" will provide also details on  sessions by the engine and matches counts.


The cli cmd  "diag ips sign   hit" is also great for determining  if hits are being match. This go along with the cli cmd "diag ips  packet status" to get status of the ips actions; ( drop, pass, reset, etc.....)


One thing you need to be aware of, the IPS sensor could be populated, but traffic is not properly handle. So you will need to kill off the  process for the IPS engine &  have it restart.

I've seen IPS sensors that are configured , but get's hanged up and needs a warm-reload without reboot the appliance.

The fnsysctl cli cmd ( a hidden command ) can be execute to find the process by looking for the ipsengine proc-id. You only need to kill the  parent proc-id and you can use  fnsysctl for that also

e.g ( killing process id #1234 with KILLSIGNAL 9 )

     fnsysctl kill -9  1234

Most cases when you have a few hundred rules and sensors, you want to use the filter and ensure you monitor traffic for that items specified. In this example I will apply a filter for   tcp and port 21

    diag ips  filter port 21
    diag ips  filter proto 6
    diag ips  filter status

Now running the cli cmd "diag ips  session list" will generate information for the above defined filters only. Here's a typical output.



Note: Ensure you clear any filters after performing any diagnostic. It's best to  clear any filters b4 you apply new filters;  

e.g

diag ips  filter  clear

The fortigate cli cmd  diag debug flow command is also a must and to ensure the policy is being matched and the traffic is  kicked to the IPS engine.

e.g








 If you are finding packets not shown punted to the IPS, than 1> check your policy(s) 2> ensue the sensor is correct 3> check the ordering of the policy(s) being matched





In  summary;
  • check for ips_sensors place within the fw-policies
  • monitor the security  logs  ips
  • diag debug flow is your friend
  • ensure packets are hitting the correct filters
  • don't be afraid to use the filters with the diag ips  cmds

The logs will show you what signature fired off,  date/time,  the resulting action ( block, alert,etc...). The sensor name, direction ,  interfaces, and threat level. If the signature that fired is a fortigate can'd signature the  fortinet  VID ( vulnerability ID ) will be listed for reference

e.g http://www.fortinet.com/ids/VID41500

 

And finally all alert should be analyze to determine true or false positive and any post-alert remediations.


Ken Felix
NSE ( network security expert) and Route/Switching Engineer
kfelix  -----a----t---- socpuppets ---dot---com

     ^      ^
=(  @  @ )=
         o 
        /  \