LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices


Reply
  Search this Thread
Old 05-06-2016, 06:49 PM   #1
kcirick
Member
 
Registered: Dec 2006
Distribution: Slackware 14.1; LFS 7.9-Systemd; Debian Jessie
Posts: 169

Rep: Reputation: 55
BLFS Firewall (iptables)


Hello,

I'm trying to learn about firewalls by going through BLFS "Setting Up a Network Firewall". I've installed iptables package and created the "Personal Firewall" script. As far as I know it is running, but how do I track/monitor activities? How do I know it is actually doing its job? The chapter doesn't say. Where do I view the logfile?

I am using 7.9 systemd version.
 
Old 05-07-2016, 12:13 PM   #2
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
You should add iptables rules for logging. e.g. http://www.thegeekstuff.com/2012/08/...s-log-packets/

Log to a place that makes sense. e.g. /var/log/iptables

Modify syslog or rsyslog to output to a file. e.g. http://www.cyberciti.biz/tips/force-...-log-file.html

Last edited by sag47; 05-07-2016 at 12:16 PM.
 
1 members found this post helpful.
Old 05-07-2016, 03:18 PM   #3
brebs
Member
 
Registered: May 2013
Posts: 89

Rep: Reputation: Disabled
Also, iptables-save shows a count of bytes & packets, per chain, which helps a bit.
 
1 members found this post helpful.
Old 05-09-2016, 05:46 AM   #4
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
You can check if you are secure here:
https://www.grc.com/x/ne.dll?bh0bkyd2
Been using shields up for years, you can scan common ports, a range of ports or a single port, find out what a port is for etc, etc.
 
1 members found this post helpful.
Old 05-09-2016, 09:30 AM   #5
kcirick
Member
 
Registered: Dec 2006
Distribution: Slackware 14.1; LFS 7.9-Systemd; Debian Jessie
Posts: 169

Original Poster
Rep: Reputation: 55
Thanks for all the feedback so far.

As it says in the firewall chapter of BLFS, it is a complex issue and there is a lot I need to learn/read.

Using the script provided in this chapter, I can view the log using "dmesg | grep 'FIREWALL'". It shows me some packet information, something like:

Code:
...snip
[17289.379163] FIREWALL:INPUT IN=wlp2s0 OUT= MAC=xx:xx:xx SRC=192.168.0.1 DST=224.0.0.1 LEN=36 TOS=0x00 PREC=0x00 TTL=1 ID=0 DF PROTO=2 
[17361.433436] FIREWALL:INPUT IN=wlp2s0 OUT= MAC=xx:xx:xx SRC=52.4.167.74 DST=192.168.0.25 LEN=40 TOS=0x00 PREC=0x00 TTL=45 ID=38160 DF PROTO=TCP SPT=80 DPT=53628 WINDOW=0 RES=0x00 RST URGP=0 
[17414.408476] FIREWALL:INPUT IN=wlp2s0 OUT= MAC=xx:xx:xx SRC=192.168.0.1 DST=224.0.0.1 LEN=36 TOS=0x00 PREC=0x00 TTL=1 ID=0 DF PROTO=2 
[17539.538090] FIREWALL:INPUT IN=wlp2s0 OUT= MAC=xx:xx:xx SRC=192.168.0.1 DST=224.0.0.1 LEN=36 TOS=0x00 PREC=0x00 TTL=1 ID=0 DF PROTO=2 
[17664.670020] FIREWALL:INPUT IN=wlp2s0 OUT= MAC=xx:xx:xx SRC=192.168.0.1 DST=224.0.0.1 LEN=36 TOS=0x00 PREC=0x00 TTL=1 ID=0 DF PROTO=2 
[17789.699223] FIREWALL:INPUT IN=wlp2s0 OUT= MAC=xx:xx:xx SRC=192.168.0.1 DST=224.0.0.1 LEN=36 TOS=0x00 PREC=0x00 TTL=1 ID=0 DF PROTO=2 
[17893.020554] FIREWALL:INPUT IN=wlp2s0 OUT= MAC=xx:xx:xx SRC=192.168.0.18 DST=255.255.255.255 LEN=171 TOS=0x00 PREC=0x00 TTL=64 ID=39966 PROTO=UDP SPT=17500 DPT=17500 LEN=151
but not sure if this normal and/or knowing what is considered suspicious / possible attack attempts? I guess there is no real answer here. I'm just trying to learn and leaving it as open-ended question...
 
Old 05-09-2016, 09:12 PM   #6
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
I have a service script and rules script for iptables that I publish (iptables.rules are my actual rules). That iptables script also has logging. It also a more involved iptables example than your average script.

See man iptables. That thoroughly discusses every option I'm using. Why did I design it that way? Because I want to easily add and remove rules without refreshing my whole firewall. I took concepts from RedHat's firewalld and made them my own.

I have chains for when I'm on my internal network vs VPN vs anywhere else.

Also notice I configure outbound rules. Configuring outbound rules goes a long way for securing a computer. Most guides you encounter won't discuss it much.

My iptables service script is what I use in a SysV init based startup. You might need to change it depending on the init system you're using. In general, you can load the firewall rules using the following command.

Code:
iptables-restore < /etc/iptables.rules
Feel free to ask additional questions.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Firewall/Iptables Help mutt4xtreme Linux - Newbie 3 02-19-2013 09:57 PM
IPTables or Firewall vijaysoft Linux - Newbie 6 07-19-2012 07:27 PM
Iptables with iptables-firewall.conf arno's matt3333 Slackware 16 06-28-2007 07:20 AM
firewall - iptables Gemenii Linux - Security 3 01-31-2007 02:24 AM
IPTABLES firewall Vs rc firewall netguy2000 Linux - Security 7 02-28-2004 04:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 02:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration