Results 1 to 8 of 8

Thread: UFW log guide/tutorial ?

  1. #1
    Join Date
    Jun 2012
    Beans
    310

    UFW log guide/tutorial ?

    Can please someone point me to some kind of beginner's guide/tutorial to read UFW log messages ? I've set up some basic rules in UFW,but then when looking at the log messages I frankly don't understand what I see,can't figure out what things like AUDIT,DST,TOS actually are,therefore I can't check if said rules are indeed doing what I wanted.Thanks.

  2. #2
    Join Date
    Feb 2008
    Location
    Texas
    Beans
    29,807
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: UFW log guide/tutorial ?

    Thread moved to Security Discussions.

  3. #3
    Join Date
    Feb 2010
    Location
    Obscurial Springs
    Beans
    15,203
    Distro
    Ubuntu Budgie Development Release

    Re: UFW log guide/tutorial ?

    Here is some community documentation , excuse me if you have seen it already.
    Last edited by cariboo; November 18th, 2012 at 05:04 AM. Reason: fixed broken link
    "Our intention creates our reality. "

    Ubuntu Documentation Search: Popular Pages
    Ubuntu: Security Basics
    Ubuntu: Flavors

  4. #4
    Join Date
    Jun 2012
    Beans
    310

    Re: UFW log guide/tutorial ?

    Thanks,I've read that page but there's no key in it to understand UFW logs.
    I've specifically asked about logs because at this point I'm kinda stuck,as I've started to add my firewall rules but then -not knowing how to read the logs- I can't decipher whether they are actually doing what I intended or something else or maybe nothing at all I've searched the forums but I couldn't find so far any specific reading on this matter.

  5. #5
    Join Date
    Sep 2011
    Beans
    1,531

    Re: UFW log guide/tutorial ?

    Bad news: I had the exact same problem and the only solution I found was to study UDP/TCP/IP traffic & packets. That only took a few months of hard-core studying on my part...

    Better news: I can give you a quick rundown.
    Code:
    Nov  11 18:24:57 daisy: [ 5287.193460] [UFW BLOCK] IN= OUT=wlan0  SRC=192.168.1.10 DST=300.120.61.72 LEN=60 TOS=0x00 PREC=0x00 TTL=64  ID=47904 DF PROTO=TCP SPT=52279 DPT=9001 WINDOW=14600 RES=0x00 SYN  URGP=0
    This is an excerpt from my log. Here's what it's telling us.

    date It's good practice to watch the dates and times. If things are out of order or blocks of time are missing then an attacker probably messed with your logs.

    [UFW BLOCK] indicates obviously that the packet was blocked.

    IN= and OUT=wlan0 indicate whether it was incoming or outgoing. So this packet was outbound on my wlan0 connection.

    SRC=192.168.1.10 This indicates the source IP, who sent the packet initially. In this case it was me. Some IPs are routable over the internet, some will only communicate over a LAN, and some will only route back to the source computer. Here's a handy guide.

    DST=300.120.61.72 This indicates the destination IP, who is meant to receive the packet. (In this case it's fictitious - 255 is the highest number possible in each octet). You can use whois.net to determine who the IP belongs to (this one belongs to Swordfish ).

    LEN=60 This indicates the length of the packet.

    TOS and PREC These are details about the packets that aren't really relevant for reading logs. They're set to 0 which means they're not relevant in this particular packet either. More here if you care.

    TTL 64 = This indicates the "Time to live" for the packet. Basically each packet will only bounce through the given number of routers before it dies and disappears. If it hasn't found its destination before the TTL expires, then the packet will evaporate. This field keeps lost packets from clogging the internet forever.

    ID=47904 Not sure what this one is, but it's not really important for reading logs. It might be ufw's internal ID system, it might be the operating system's ID.

    PROTO=TCP This indicates the protocol of the packet. In this case it was TCP. The other one you'll see is UDP. More explanation here.

    SPT=52279
    This indicates the source port. My computer generated this packet on port 52279. This is a random high port which is typical.This is a handy resource to determine what services may have started a connection. In most connections you'll see one registered port and one high unregistered one. The server typically uses the registered port & the client uses the high one. So in this instance, the source was me and it was a random high number, so I'm the client.

    DPT=9001 This indicates the destination port. The receiving computer is listening on port 9001 for a connection. This is a registered port for a few different services, so the destination was the server. I run Tor so I can make a reasonable assumption that this was a Tor packet. The source & destination port will be the most important fields to understand (along with source & destination IPs) when dissecting firewall logs.

    WINDOW=14600 This indicates the size of packet the sender is willing to receive.

    RES=0x00 This bit is reserved for future use & is always set to 0. Basically it's irrelevant for log reading purposes.

    SYN URGP=0 SYN indicates that this connection requires the three-way handshake typical of TCP connections. URGP indicates whether the urgent pointer field is relevant. 0 means it's not. Doesn't really matter for firewall log reading.

    Conclusion: If I wanted to use my firewall while using Tor, then I have not set UFW up properly. I need to add a rule to allow out TCP port 9001.
    I hope that helps.
    Last edited by Ms. Daisy; November 18th, 2012 at 08:26 PM.

  6. #6
    Join Date
    Sep 2011
    Beans
    1,531

    Re: UFW log guide/tutorial ?

    This helped me to understand firewall logs and, more importantly, what's worrisome and what's not:

    https://wiki.ubuntu.com/BasicSecurity/DidIJustGetOwned

  7. #7
    Join Date
    Jun 2012
    Beans
    310

    Re: UFW log guide/tutorial ?

    Thanks a lot for taking the time to explain all this,I was kinda surprised seeing that there's not much documentation around on this matter (or,if there is,it's hidden really well ).
    Please excuse me for shamelessly asking,but could you also briefly explain what log lines like this really mean
    [UFW AUDIT] IN= OUT=eth0 SRC=192.168.1.xxx DST=99.239.231.99(...)
    what is the firewall doing when I see "AUDIT" in the log,is it actually dropping or allowing that particular connection?

  8. #8
    Join Date
    Sep 2011
    Beans
    1,531

    Re: UFW log guide/tutorial ?

    I didn't find any written documentation so I just messed with my own ufw logging levels to see what happens.

    You can set rules in ufw to deny and to allow. Audit shows connections that were allowed but did not specifically match ufw allowed rules (aside from "allow out all"). If you want to know about every connection your computer makes then audit is handy. Otherwise it will just fill up your hard drive with logs. You've probably got the logging set to medium or high, which is when audits are reported by ufw. Change it to low and the audits will go away (they did for me).

    Code:
    sudo ufw logging low
    Last edited by Ms. Daisy; November 20th, 2012 at 02:31 AM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •