LinuxCBT Firewall Notes
LinuxCBT Firewall Notes
a. echo-request - PING
b. echo-reply - pong
PING - local system sends via OUTPUT chain an echo-request(PING)
Remote system received echo-request in its INPUT chain ->
Remote system responds with an echo-reply(Pong)
-p icmp, --protocol icmp
--icmp-type name/number
2. Deny ICMP echo-replies from all hosts
a. /sbin/iptables -A INPUT -p icmp --icmp-type echo-reply -j DROP
3. Drop echo-replies from our system to all hosts
Match multiple ports with fewer rules
Filter traffic to ports 8080 and 23
/sbin/iptables -A INPUT -p tcp --dport web-cache -j DROP
/sbin/iptables -A INPUT -p tcp --dport telnet -j DROP
/sbin/iptbles -A INPUT -p tcp -m multiport --destination-port 8080,23 -s ! 127.0.0.1 -j DROP
/sbin/iptbles -A INPUT -p tcp -m multiport --destination-port 8080,23 -s 192.168.1.30 -j DROP
MAC ADDRESS FILTERING:
Deny access to our telnet service from IP Address: 192.168.1.10
/sbin/iptables -A INPUT -p tcp -m mac --mac-source 00:02:B3:98:41:08
Note: Filtering based on MAC(Layer2) address is more secure than filtering based on IP(Layer3) address because the IP
address can easily be changed.
If user changes Layer3 address of host that matches our MAC rule, the rule still applies.
The State Machine/IPTables' Statefullness (TCP/UDP/ICMP)
NEW,ESTABLISHED,RELATED,INVALID
Business Rule: Permit Host to initiate(SYN) but deny other hosts from initiating traffic to our hosts
/sbin/iptables -I INTRANET 3 -m state --state ESTABLISHED -j ACCEPT
/sbin/iptables -A OUTPUT -m state --state NEW,ESTABLISHED -j ACCEPT
Note: NEW means first SYN traffic
Targets:
ACCEPT -> sends packet to other rules or process
DROP -> sends no courtesy indication to client/calling-host
REJECT -> courtesy message is sent to client
REDIRECT -> applied to PREROUTING chain of NAT table - local ports ONLY
LOG -> allows us to log using SysLog
Business Rule: Log all traffic destined to 192.168.1.20/10.0.0.1
LOG ALL except VNC from 192.168.1.100
/sbin/iptables -R INTRANET 1 -m multiport -p tcp --destination-port ! 5801,5901 -j LOG
Prefix interesting traffic with a log prefix
--log-prefix "SSH ACCESS ATTEMPT:"
Prefix unauthorized traffic with "SERVICE NAME UNAUTHORIZED ACCESS ATTEMPT"
--log-tcp-options
--log-ip-options
--log-tcp-sequence
--log-level debug-emerg (warning)