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 - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 10-01-2006, 03:29 AM   #1
craftybytes
Member
 
Registered: Jan 2006
Location: Killarney, QLD Australia
Distribution: Mepis 3.4-3; Puppy 2.12; WinXP Pro (rarely)
Posts: 54

Rep: Reputation: 15
Wink Iptables & UID issues


Hi group,

QUESTION: If I include the following to my iptables firewall script in /etc/rc.firewall - what code do I add to it to allow me to log (confirm) that script snippet works?

"# Allow packets by UID
Listuid="$(gawk -F:'{print $3}' /etc/passwd)"
for Xuid in $Listuid; do
iptables -t filter -A chk-own -o ppp0 -m owner --uid-owner $Xuid -j RETURN
done
iptables -t filter -A chk-own -m limit --limit 10/s -j logdrop5
"
and for 'logdrop5':

"iptables -N logdrop5
iptables -A logdrop5 -j LOG --log-prefix "ILLEGAL packet owner: "
iptables -A logdrop5 -j DROP
"

NOTE:- the "logdrop5" section logs and drops the packet ONLY if it is illegal - not if it is ok. I also want to log if it IS OK (to confirm that the 'match' option is working).

Any help would be appreciated ..).

Oz-Rod
 
Old 10-01-2006, 11:03 AM   #2
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
Just add the same rule with a log target before the return:
Code:
iptables -A chk-own -o ppp0 -m owner --uid-owner $Xuid -j LOG --log-prefix "OK packet owner: "
You may want to change $Xuid to a known OK uid just for testing, rather than creating a log rule for each uid.

BTW "-t filter" is redundant. The filter table is the default if no other is specified.

Last edited by bulliver; 10-01-2006 at 11:06 AM.
 
Old 10-01-2006, 08:04 PM   #3
craftybytes
Member
 
Registered: Jan 2006
Location: Killarney, QLD Australia
Distribution: Mepis 3.4-3; Puppy 2.12; WinXP Pro (rarely)
Posts: 54

Original Poster
Rep: Reputation: 15
Hi bulliver,

Thanks for the reply! Actually reworked the check code to the following:

#Listuid="$(gawk -F:'{print $3}' /etc/passwd)"
#for X in $Listuid ; do
# if [[ $X == 1000 ]]; then
# iptables -A chk-own -m limit --limit 10/s -j logdrop5
# fi
#done
#iptables -A chk-own -o ppp0 -m owner --uid-owner $X -j "output chain name"

This seems to be working OK for the moment - will have to monitor my logs.

Thanks anyway.

Oz-Rod
 
  


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
Changing the UID of a Physical Volume to a specific UID jambraun Linux - Newbie 2 02-09-2006 02:34 PM
FREEBSD5.3 platform: PHP setcookie() successful, but $uid = $_COOKIE['uid']; fail tclwp Programming 1 03-30-2005 08:05 PM
vpopmail:- How can we efficiently use uid & gid amit_28oct Linux - Networking 4 09-30-2004 01:02 AM
Samba & IPTABLES & Network Drives Oh My! logicdisaster Linux - Networking 3 06-03-2004 06:07 PM
Iptables & squid issues sedulous Linux - Networking 1 10-05-2003 02:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 04:26 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