Linux Iptables

LogZilla App Store application: Linux Iptables

Linux Iptables

Rule Function

Iptables is the basic firewall functionality built into linux. It is a user-space utility program that allows a system administrator to configure the IP packet filter rules of the Linux kernel firewall. The filters are organized in different tables, which contain chains of rules for how to treat network traffic packets.

Note that this rule can also be used with linux Uncomplicated Firewall (UFW). UFW is a wrapper on top of Iptables to make Iptables configuration and administration easier.

The purpose of this rule is to set user tags various user tags for the fields in the Iptables log messages.

Vendor Documentation

Incoming Log Format

The log format is comprised of space-separated fields, most of which are in the form of key=value. These fields are listed in the next section. This log message is logged as a linux kernel message (or in some cases produced by certain network devices).

User Tags

TaggedTag NameField NameExampleDescription
IntInINeth0incoming network interface
IntOutOUTeth0outgoing network interface
MACMAC4a:2a:b8:8e:09:87:fe:00:00:00:01:01:08:00interface MAC address
SrcIPSRC185.153.196.126source IP address
DstIPDST134.122.74.164destination IP address
ProtocolPROTOTCPnetwork protocol
SPT50369source IP port
DstPortDPT110dest IP port
LEN40length of the packet
TOS0x00"TOS" field of the IP packet header
PREC0x00"precedence" field of the IP packet header
TTL246packet time-to-live
ID57949ufw/os internal id
WINDOW1024size of packet the sender is willing to receive
RES0x00reserved for future use, always 0
SYN URGP0two parts: 1) whether connection requires 3-way-handshake; 2) whether urgent field is relevant

Lua User Tag Map

USERTAGS_MAP = {  
    IN = "IntIn",  
    OUT = "IntOut",  
    MAC = "MAC",  
    SRC = "SrcIP",  
    DST = "DstIP",  
    PROTO = "Protocol",  
    SPT = "SrcPort",  
    DPT = "DstPort",  
}

HC Tags

HC_TAGS={
    "SrcIP",
    "DstIP",
    "MAC",
    "SrcIP to DstIP",
    "SrcIP to Port"
}

Field Notes

MAC

This provides a 14-byte combination of the Destination MAC, Source MAC, and EtherType fields, following the order found in the Ethernet II header.

SRC (and DST)

This indicates the source IP, who sent the packet initially (or in the case of DST the recipient). Some IPs are routable over the internet, some will only communicate over a LAN, and some will only route back to the source computer.

PROTO

This field will mainly be one of: TCP, UDP, ICMP.

Log Examples

Packet blocked by firewall IN=eth0 OUT= MAC=4a:2a:b8:8e:09:87:fe:00:00:00:01:01:08:00 SRC=11.22.33.44 DST=55.66.77.88 LEN=40 TOS=0x00 PREC=0x00 TTL=246 ID=57949 PROTO=TCP SPT=50369 DPT=110 WINDOW=1024 RES=0x00 SYN URGP=0

Linux Iptables | LogZilla Documentation