20:59:32 #startmeeting IPTABLES 20:59:32 Meeting started Thu Sep 15 20:59:32 2011 UTC. The chair is bodhi_zazen. Information about MeetBot at http://wiki.debian.org/MeetBot. 20:59:32 Useful Commands: #action #agreed #halp #info #idea #link #topic. 20:59:39 i already have the odt :D 20:59:52 The topic of today's classroom is iptables, commonly referred to as your firewall. 20:59:58 The goal of this classroom is to explain the basic syntax of iptables. 21:00:11 Many people are intimidated by iptables. 21:00:34 if you wish, there is a graphical front end - http://docs.fedoraproject.org/en-US/Fedora/16/html/Security_Guide/sect-Security_Guide-Firewalls-Basic_Firewall_Configuration.html 21:00:46 but today I was going to discuss the rules / syntax 21:01:25 Honestly, one of the hardest parts is a basic understanding of networking 21:01:37 I would like to cover "the basics" here 21:02:03 Does everyone here understand ip addresses ? public vs private ? 21:02:18 (yep) 21:02:26 *we are going to talk ipv4 today - ipv6 is similar * 21:02:38 yes 21:02:40 yep, 21:02:58 yes 21:03:07 OK, network protocols - icmp / tcp / udp ? 21:03:12 yes 21:03:16 yup 21:03:16 thats correct 21:03:17 Yes and yes. 21:03:24 the basic :D 21:03:34 not familiar with icmp 21:03:45 icmp is "ping" among other functions 21:04:01 ok, got it 21:04:10 Anyone want to see what a three way handshake looks like on tcpdump ? 21:04:27 ok. 21:04:40 yes 21:04:55 why not? 21:05:07 sounds interesting. 21:05:08 im taking notes :D 21:05:11 http://fpaste.org/sVBh/ 21:05:32 The important points there - 21:05:54 on line 8 , my clinet is using port 35641 21:06:15 Flags [S] = syn 21:06:47 Line 10 - server sends an ack 21:07:16 Line 17 , client requests web page , Flag = P or push 21:07:44 Lines 24 and 28 server sends data, client acknowledges 21:08:06 The first packet to the server would be a NEW 21:08:14 The first response from the server is RELATED 21:08:36 After that the connection is ESTABLISHEDl 21:09:05 Any background questions ? 21:09:12 #topic PORTS 21:09:40 I found it useful to think of ip addresses as post offices or apartment buildings 21:09:59 so servers listen on a specific port on your server ip address 21:10:16 How do you open a port ? 21:10:28 Install and start a service (apache, ssh, etc) 21:10:41 How do you list your open ports ? 21:10:51 From localhost 21:10:53 lsof -i -n -P 21:11:03 netstat -ntulp 21:11:26 From another client on your lan, nmap -v -A ip_address 21:11:43 How do you close a port ? 21:11:50 1. Stop the service 21:11:52 with iptables :D or stopping the daemon 21:12:07 2. Or you can do it with iptables, BUT .... 21:12:21 IMO better to stop the server if you are not going to use it 21:12:54 #topic packets 21:13:03 http://www.linuxhomenetworking.com/wiki/images/f/f0/543x760xIptables.gif.pagespeed.ic.A-oBumv4CC.png 21:13:17 Let me show you a summary picture ^^ 21:13:43 Here the firewall has 2 NIC, one listening on Network A, the other on B 21:14:03 The picture is easier to understand if you ignore all the mangle boxes =) 21:14:30 A packet comes into the box -> PREROUTING tables -> notice the routing decision ? 21:15:02 If the packet is going somewhere else it goes out the FORWARD and POSTROUTING -> Network B 21:15:09 That is basically NAT 21:15:48 If it is going to the firewall, or server, then it goes through INPUT and to your applications (firefox or what have you) 21:16:15 #topic iptables rules 21:16:29 OK, now we get to the details 21:16:34 Any questions so far ? 21:16:43 no 21:16:45 no 21:16:59 nope. ;) 21:17:00 no 21:17:04 OK, so the general syntax of iptables is iptables