LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 01-08-2006, 10:55 PM   #1
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Rep: Reputation: 62
What does this line in iptables do?


I use Firestarter, and want to block communications from specific ips to specific ports. In Firestarter there doesn't seem to be a way to block inputs, but you can block outputs by IP. Seemed to me that should work just as well. I told Firestarter to deny service to a specific ip on ports 6696-6699. Iptables wound up looking (partially) like this:
Code:
...
Chain LSO (18 references)
target     prot opt source               destination
LOG_FILTER  all  --  0.0.0.0/0            0.0.0.0/0
LOG        all  --  0.0.0.0/0            0.0.0.0/0           limit: avg 5/sec burst 5 LOG flags 0 level 6 prefix `Outbound '
REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-port-unreachable

Chain OUTBOUND (1 references)
target     prot opt source               destination
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
LSO        tcp  --  68.209.140.97        0.0.0.0/0           tcp dpts:6696:6699
LSO        udp  --  68.209.140.97        0.0.0.0/0           udp dpts:6696:6699
...
Unfortunately ip 68.209.140.97 here is still able to connect via the identified ports. Exactly what is 'LSO' supposed to be doing?
 
Old 01-08-2006, 11:43 PM   #2
scuzzman
Senior Member
 
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
I don't think LSO is a valid action... It's probably defined higher in the file.
 
Old 01-09-2006, 01:12 AM   #3
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Original Poster
Rep: Reputation: 62
The only definition I can see is the CHAIN statement at the top of my quoted code. Looks to me like it should be REJECTing everything, but it's not. Only thing I can figure out is that perhaps since I can't block the original INPUT communication the link has become ESTABLISHED, but that doesn't really make sense either, else why does Firestarter give me the option to block outgoing communication by IP address. ... Or is that only outgoing communications initialized locally.
 
Old 01-09-2006, 02:34 AM   #4
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,291

Rep: Reputation: 62
LSO looks like it is a user-created chain, probably created by the firestarter program, i would need to see the whole script that firstarter creates to be certain.
 
Old 01-09-2006, 04:09 AM   #5
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Original Poster
Rep: Reputation: 62
By 'whole script' Do you mean the entire output of iptables -L -n?
Code:
debian:~# iptables -L -n
Chain INBOUND (1 references)
target     prot opt source               destination
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpts:6696:6699
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpts:6696:6699
LSI        all  --  0.0.0.0/0            0.0.0.0/0

Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     tcp  --  68.87.85.98          0.0.0.0/0           tcp flags:!0x17/0x02
ACCEPT     udp  --  68.87.85.98          0.0.0.0/0
ACCEPT     tcp  --  68.87.69.146         0.0.0.0/0           tcp flags:!0x17/0x02
ACCEPT     udp  --  68.87.69.146         0.0.0.0/0
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           limit: avg 10/sec burst 5
DROP       all  --  0.0.0.0/0            255.255.255.255
DROP       all  --  0.0.0.0/0            192.168.123.255
DROP       all  --  224.0.0.0/8          0.0.0.0/0
DROP       all  --  0.0.0.0/0            224.0.0.0/8
DROP       all  --  255.255.255.255      0.0.0.0/0
DROP       all  --  0.0.0.0/0            0.0.0.0
DROP       all  --  0.0.0.0/0            0.0.0.0/0           state INVALID
LSI        all  -f  0.0.0.0/0            0.0.0.0/0           limit: avg 10/min burst 5
INBOUND    all  --  0.0.0.0/0            0.0.0.0/0
LOG_FILTER  all  --  0.0.0.0/0            0.0.0.0/0
LOG        all  --  0.0.0.0/0            0.0.0.0/0           LOG flags 0 level 6 prefix `Unknown Input'

Chain FORWARD (policy DROP)
target     prot opt source               destination
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           limit: avg 10/sec burst 5
LOG_FILTER  all  --  0.0.0.0/0            0.0.0.0/0
LOG        all  --  0.0.0.0/0            0.0.0.0/0           LOG flags 0 level 6 prefix `Unknown Forward'

Chain LOG_FILTER (5 references)
target     prot opt source               destination
DROP       tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:1026
DROP       udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:1026
DROP       tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:1027
DROP       udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:1027
DROP       tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:1025
DROP       udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:1025

Chain LSI (2 references)
target     prot opt source               destination
LOG_FILTER  all  --  0.0.0.0/0            0.0.0.0/0
LOG        tcp  --  0.0.0.0/0            0.0.0.0/0           tcp flags:0x17/0x02 limit: avg 1/sec burst 5 LOG flags 0 level 6 prefix `Inbound '
DROP       tcp  --  0.0.0.0/0            0.0.0.0/0           tcp flags:0x17/0x02
LOG        tcp  --  0.0.0.0/0            0.0.0.0/0           tcp flags:0x17/0x04 limit: avg 1/sec burst 5 LOG flags 0 level 6 prefix `Inbound '
DROP       tcp  --  0.0.0.0/0            0.0.0.0/0           tcp flags:0x17/0x04
LOG        icmp --  0.0.0.0/0            0.0.0.0/0           icmp type 8 limit: avg 1/sec burst 5 LOG flags 0 level 6 prefix `Inbound '
DROP       icmp --  0.0.0.0/0            0.0.0.0/0           icmp type 8
LOG        all  --  0.0.0.0/0            0.0.0.0/0           limit: avg 5/sec burst 5 LOG flags 0 level 6 prefix `Inbound '
DROP       all  --  0.0.0.0/0            0.0.0.0/0

Chain LSO (18 references)
target     prot opt source               destination
LOG_FILTER  all  --  0.0.0.0/0            0.0.0.0/0
LOG        all  --  0.0.0.0/0            0.0.0.0/0           limit: avg 5/sec burst 5 LOG flags 0 level 6 prefix `Outbound '
REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-port-unreachable

Chain OUTBOUND (1 references)
target     prot opt source               destination
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
LSO        tcp  --  68.209.140.97        0.0.0.0/0           tcp dpts:6696:6699
LSO        udp  --  68.209.140.97        0.0.0.0/0           udp dpts:6696:6699
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0

Chain OUTPUT (policy DROP)
target     prot opt source               destination
ACCEPT     tcp  --  192.168.123.151      68.87.85.98         tcp dpt:53
ACCEPT     udp  --  192.168.123.151      68.87.85.98         udp dpt:53
ACCEPT     tcp  --  192.168.123.151      68.87.69.146        tcp dpt:53
ACCEPT     udp  --  192.168.123.151      68.87.69.146        udp dpt:53
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
DROP       all  --  224.0.0.0/8          0.0.0.0/0
DROP       all  --  0.0.0.0/0            224.0.0.0/8
DROP       all  --  255.255.255.255      0.0.0.0/0
DROP       all  --  0.0.0.0/0            0.0.0.0
DROP       all  --  0.0.0.0/0            0.0.0.0/0           state INVALID
OUTBOUND   all  --  0.0.0.0/0            0.0.0.0/0
LOG_FILTER  all  --  0.0.0.0/0            0.0.0.0/0
LOG        all  --  0.0.0.0/0            0.0.0.0/0           LOG flags 0 level 6 prefix `Unknown Output'
debian:~#
 
Old 01-09-2006, 05:04 AM   #6
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,291

Rep: Reputation: 62
The script will be a text file, but I don't use debian or firestarter so I don't know where it would reside. Most distros will have
it usually it will be /etc/rc.d/rc.firewall, but a lot of distro are now moving the scripts around and changing their names. By the looks you also have a LSI as well as LSO, i would say that LSI would be INPUT and LSO would be OUTPUT chain perhaps, but it does look like a chain created by firestarter.
 
Old 01-09-2006, 07:01 PM   #7
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Original Poster
Rep: Reputation: 62
Quote:
The script will be a text file, ...
By the time I studied enough to figureout where that script was, I got a couple ideas about different ways to handle this situation thru the gui, but it still looks to me like denying service on the output side should stop the connection. It doesn't though. Anyway, I'll try my new ideas tonight.

I didn't include the entire script here. It's pretty long, but here is the definition of LSI & LSO:
Code:
# Create a new log and stop input (LSI) chain.
$IPT -N LSI 2> /dev/null
$IPT -F LSI
$IPT -A LSI -j LOG_FILTER
if [ "$log_supported" ]; then
        # Syn-flood protection
        $IPT -A LSI -p tcp --syn -m limit --limit 1/s -j LOG --log-level=$LOG_LEVEL --log-prefix "Inbound "
        $IPT -A LSI -p tcp --syn -j $STOP_TARGET
        # Rapid portscan protection
        $IPT -A LSI -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j LOG --log-level=$LOG_LEVEL --log-prefix "Inbound "
        $IPT -A LSI -p tcp --tcp-flags SYN,ACK,FIN,RST RST -j $STOP_TARGET
        # Ping of death protection
        $IPT -A LSI -p icmp --icmp-type echo-request -m limit --limit 1/s -j LOG --log-level=$LOG_LEVEL --log-prefix "Inbound "
        $IPT -A LSI -p icmp --icmp-type echo-request -j $STOP_TARGET
        # Log everything
        $IPT -A LSI -m limit --limit 5/s -j LOG --log-level=$LOG_LEVEL --log-prefix "Inbound "
fi
$IPT -A LSI -j $STOP_TARGET # Terminate evaluation

# Create a new log and stop output (LSO) chain.
$IPT -N LSO 2> /dev/null
$IPT -F LSO
$IPT -A LSO -j LOG_FILTER
if [ "$log_supported" ]; then
        # Log everything
        $IPT -A LSO -m limit --limit 5/s -j LOG --log-level=$LOG_LEVEL --log-prefix "Outbound "
fi
$IPT -A LSO -j REJECT # Terminate evaluation

Last edited by rickh; 01-09-2006 at 07:05 PM.
 
Old 01-09-2006, 07:27 PM   #8
Capt_Caveman
Senior Member
 
Registered: Mar 2003
Distribution: Fedora
Posts: 3,658

Rep: Reputation: 69
Looking at the rules you posted, you have ports 6696:6699 accepted by the INBOUND chain here:
Code:
Chain INBOUND (1 references)
target     prot opt source               destination
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpts:6696:6699
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpts:6696:6699
LSI        all  --  0.0.0.0/0            0.0.0.0/0
And you're blocking outgoing traffic to that IP:
Code:
 
Chain OUTBOUND (1 references)
target     prot opt source               destination
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
LSO        tcp  --  68.209.140.97        0.0.0.0/0           tcp dpts:6696:6699
LSO        udp  --  68.209.140.97        0.0.0.0/0           udp dpts:6696:6699
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
Which sends them to LSO where the packets get rejected. Though this would get trumped by the the ESTABLISHED,RELATED rule if they initiate the connection. So you're allowing incoming connections but blocking outgoing ones. It sounds like you have this backwards...
 
Old 01-09-2006, 07:35 PM   #9
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Original Poster
Rep: Reputation: 62
I think you're right. The problem is that Firestarter's gui does not have such a blocking option for incoming packets. I want most people to have access to those ports, but NOT specific IP-s. The gui does have an option, also on the outgoing rules screen, to deny ANY connections to a given host IP. That's what I'm going to test later tonight.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
C++ text file line by line/each line to string/array Dimitris Programming 15 03-11-2008 08:22 AM
iptables v1.2.9: Unknown arg `/sbin/iptables' Try `iptables -h' or 'iptables --help' Niceman2005 Linux - Security 4 12-29-2005 08:20 PM
iptables line enrique_arong Linux - Newbie 1 06-09-2004 02:46 PM
simple Iptables line enrique_arong Linux - Networking 1 06-09-2004 07:14 AM
linux scripting help needed read from file line by line exc commands each line read atokad Programming 4 12-26-2003 10:24 PM

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

All times are GMT -5. The time now is 06:58 AM.

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