Linux Firewall: For The Office and Home
Linux Firewall: For The Office and Home
Todays Agenda
Introduction TCP/IP Recap Firewall Basics ipchains, iptables (Netfilter) Implementation for home use Implementation for business use Firewall Management Demo
Introduction
Why need a firewall?
Increased network security Access Control (Network/Transport Level) Logging
Why Linux?
Its FREE Not difficult to use!? Low hardware cost Flexible Lots of features compared with commercial counterpart Lots of Support!? Always evolving and improving (thanks to the open source community)
TCP
ICMP
Device Driver
UDP
IP
Device Driver
src, dst
eth0, eth1
Server
TCP/UDP
TCP/UDP
IP
Device Driver
IP
Device Driver
80
20,21
137
53
TCP
IP
Device Driver
UDP
192.168.0.166 202.252.123.1
Device Driver
eth0
eth1
SYN (1000)
Active Open
Server
Passive Open
ACK, [DATA]
Connection Established
ACK (2300), FIN (1500) ACK (1501) ACK (1501), FIN (2400)
Connection Established
Client Close
ACK (2401)
Server Close
UDP
Stateless communication (no session, Less reliable, fast)
IP
Addressing, routing (best effort)
ICMP
Diagnostic (dangerous?)
Network A
Network B
100% safe
Any software has bugs and vulnerabilities, so does any firewall
Drop
Command or Script (up to you) No Port-forward Port-forward: use with ipmasqadm portfw
SYN (1000)
Active Open
Server
Passive Open
ACK, [DATA]
Connection Established
ACK (2300), FIN (1500) ACK (1501) ACK (1501), FIN (2400)
Connection Established
Client Close
ACK (2401)
Server Close
input
eth0
eth1
output
Implementation Tips:
Use common Linux distributions
PC with >1 NIC card, hard disk for the O/S Install and harden O/S Load module (usually already loaded for default installation Run script
Internet
Firewall
Cable, ADSL, or Dial-up Modem
Aim: Masquerade all out going traffic Allow all outgoing traffic Filter in-coming traffic
Loopback interface:
LOOPBACK_INTERFACE="lo
Internal interface:
LOCAL_INTERFACE_1="eth1"
What is ! y ???
Anyone
SYN (1000)
Active Open
Your firewall
ACK, [DATA]
Connection Established
ACK (2300), FIN (1500) ACK (1501) ACK (1501), FIN (2400)
Connection Established
Client Close
ACK (2401)
Server Close
FTP data
ipchains -A input -i $EXTERNAL_INTERFACE -p tcp --destination-port 20 -j ACCEPT
ICMP Replies
ipchains -A input -i $EXTERNAL_INTERFACE -p icmp --icmp-type echo-reply -j ACCEPT ipchains -A input -i $EXTERNAL_INTERFACE -p icmp --icmp-type destination-unreachable -j ACCEPT ipchains -A input -i $EXTERNAL_INTERFACE -p icmp --icmp-type time-exceeded -j ACCEPT
Home Use:
Step-by-Step Setup - Final Step
Enable IP forwarding echo "1" > /proc/sys/net/ipv4/ip_forward
Office Use
Dont rely on GUI GUI may not be flexible enough for you Commands gives you more control Learn it (you or your net admin staff) Put together a firewall script
Internet
Firewall
router
DMZ (servers)
Aim: Masquerade all out going traffic Filter both in-coming and out-going traffic Port forward incoming traffic for your servers
Internal LAN 1
Firewall
Internal LAN 2
Loopback interface:
LOOPBACK_INTERFACE="lo
Internal interface:
LOCAL_INTERFACE_1="eth1 LOCAL_INTERFACE_2=eth2
Office Use:
Step-by-Step Setup - Final Step
Enable IP forwarding echo "1" > /proc/sys/net/ipv4/ip_forward
Troubleshooting Tips
Dont panic when it doesnt work Use -l (logging) to help you Logs are logged in syslog Location:
/var/log/messages
Linux Firewall
By Robert L. Ziegler
Thank You!
Email: [email protected]