Welcome to the { mindfrost82.com } forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Linux > Linux Networking

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old 07-04-2008, 08:31 AM
Mark Hobley
 
Posts: n/a
Re: iptables: allowing only listed hosts to connect to a port

Pascal Hambourg <boite-a-spam@plouf.fr.eu.org> wrote:
> Just as expected. Are you really really 100% sure that hosts outside the
> list ranges can connect to the port ?


I am using tcpdump -nA port 7500 on the machine. This shows entries from
various hosts outside of the allowable range. An example is shown below:

08:10:54.949811 IP 216.139.243.81.1630 > 10.0.0.8.7500: P 1:1208(1207)
ack 1 win 65535

The address 216.139.243.81 is not on my access list. I want to restrict
traffic on that port to hosts within the selected territories of the
United Kingdom of Great Britain.

The 216.139.243.81 access above is coming from a Microsoft Windows based
robot in Texas, USA.

I have a list of ISP internet network addresses, that I want to use as the
permitted access list against the port.

Regards,

Mark.

--
Mark Hobley,
393 Quinton Road West,
Quinton, BIRMINGHAM.
B32 1QE.
Reply With Quote
  #12 (permalink)  
Old 07-04-2008, 10:36 AM
Pascal Hambourg
 
Posts: n/a
Re: iptables: allowing only listed hosts to connect to a port

Mark Hobley a écrit :
> Pascal Hambourg <boite-a-spam@plouf.fr.eu.org> wrote:
>
>>Just as expected. Are you really really 100% sure that hosts outside the
>>list ranges can connect to the port ?

>
> I am using tcpdump -nA port 7500 on the machine. This shows entries from
> various hosts outside of the allowable range.


Tcpdump captures traffic at the interface, before incoming packets enter
the iptables chains and after outgoing packets leave the iptables
chains. It shows all incoming SYN requests from any source, but I guess
only allowed sources get a SYN/ACK reply.

In short :

interface --- iptables --- TCP/IP stack --- process
^
|
tcpdump is here
Reply With Quote
  #13 (permalink)  
Old 07-04-2008, 11:58 AM
Baho Utot
 
Posts: n/a
Re: iptables: allowing only listed hosts to connect to a port

Chipmunk wrote:

> Baho Utot wrote:
>> Mark Hobley wrote:
>>
>>> Pascal Hambourg <boite-a-spam@plouf.fr.eu.org> wrote:
>>>
>>>> Weird. Are there other rules in the ruleset ? What happens if you
>>>> remove all the ACCEPT rules and leave only the DROP rule ?
>>> There are no additional rules in the ruleset. The setup script is as
>>> posted.
>>>
>>> If I just have the drop line, all traffic to the port is dropped.
>>>
>>> If I invert the script as follows:
>>>
>>> iptables -A INPUT -p tcp --dport 7500 -jDROP
>>>
>>> for addr in $ALLOWED
>>> do
>>> iptables -A INPUT -s $addr -p tcp --dport 7500 -jACCEPT
>>> done
>>>
>>> This produces a filter table as follows:
>>>
>>> DROP tcp -- 0.0.0.0/0 0.0.0.0/0 tcp
>>> dpt:7500
>>> ACCEPT tcp -- 10.0.0.0/8 anywhere tcp
>>> dpt:7500
>>> ACCEPT tcp -- 192.168.0.0/16 anywhere tcp
>>> dpt:7500
>>> ACCEPT tcp -- 51.0.0.0/8 anywhere tcp
>>> dpt:7500
>>> ACCEPT tcp -- 62.30.0.0/16 anywhere tcp
>>> dpt:7500
>>> ACCEPT tcp -- 80.0.0.0/13 anywhere tcp
>>> dpt:7500
>>>
>>> However, in this scenario, all network traffic to port 7500 remains
>>> blocked, even from the accepted ports, presumable because the first rule
>>> produces a match, and the rest of the table is then ignored.
>>>
>>> iptables -V reveals:
>>>
>>> iptables v1.3.6
>>>
>>> cat /proc/version reveals:
>>>
>>> Linux version 2.6.18-6-486 (Debian 2.6.18.dfsg.1-18etch6)
>>>
>>> Regards,
>>>
>>> Mark.
>>>

>>
>> Yes working correctly.
>> The first rule drops the packet and the other rules then match nothing.
>>

>
> Erm shouldn't the DROP rule be at after the accept rules?


Yes that's just what I said. The first rule drops the packet the others see
nothing. Conclusion IPTABLES and script working as written. The order of
the rules matters -----> producing exactly what he described :)

--
Tayo'y mga Pinoy
Reply With Quote
  #14 (permalink)  
Old 07-04-2008, 09:30 PM
Mark Hobley
 
Posts: n/a
Re: iptables: allowing only listed hosts to connect to a port

Pascal Hambourg <boite-a-spam@plouf.fr.eu.org> wrote:
> Tcpdump captures traffic at the interface, before incoming packets enter
> the iptables chains and after outgoing packets leave the iptables
> chains. It shows all incoming SYN requests from any source, but I guess
> only allowed sources get a SYN/ACK reply.
>
> In short :
>
> interface --- iptables --- TCP/IP stack --- process
> ^
> |
> tcpdump is here


Hmmm, for some reason, the traffic is reaching the application process,
because tcpdump also shows reply traffic coming from the server process
to the unauthorized client:

21:22:07.637908 IP 202.100.82.9.22091 > 10.0.0.8.7500: F 2082:2082(0)
ack 3973 win 65535
E..().@.p....dR
....VK.@}D......P...T.........
21:22:07.638071 IP 10.0.0.8.7500 > 202.100.82.9.22091: . ack 2083 win
11680
E..(..@.@..[
.....dR .@VK....}D..P.-.'...

Could it be that the traffic is not being recognized as tcp type
traffic? I am also wondering if there is some sort of limit in iptables
causing it to somehow bomb out before the final drop line is reached. In
reality my allow list has some 2000 or so British networks listed (taken from
http://www.countryipblocks.net). The list appears to be complete if I do
iptables -L -n. This lists shows all the networks, and tne final drop
line, so I know that my script is populating iptables.

I am performing further tests.

Regards,

Mark.

--
Mark Hobley,
393 Quinton Road West,
Quinton, BIRMINGHAM.
B32 1QE.
Reply With Quote
  #15 (permalink)  
Old 07-05-2008, 07:06 AM
Klunk
 
Posts: n/a
Re: iptables: allowing only listed hosts to connect to a port

On Fri, 04 Jul 2008 21:30:24 +0100, Mark Hobley passed an empty day by
writing:

> Pascal Hambourg <boite-a-spam@plouf.fr.eu.org> wrote:
>> Tcpdump captures traffic at the interface, before incoming packets
>> enter the iptables chains and after outgoing packets leave the iptables
>> chains. It shows all incoming SYN requests from any source, but I guess
>> only allowed sources get a SYN/ACK reply.
>>
>> In short :
>>
>> interface --- iptables --- TCP/IP stack --- process
>> ^
>> |
>> tcpdump is here

>
> Hmmm, for some reason, the traffic is reaching the application process,
> because tcpdump also shows reply traffic coming from the server process
> to the unauthorized client:
>
> 21:22:07.637908 IP 202.100.82.9.22091 > 10.0.0.8.7500: F 2082:2082(0)
> ack 3973 win 65535
> E..().@.p....dR
> ...VK.@}D......P...T.........
> 21:22:07.638071 IP 10.0.0.8.7500 > 202.100.82.9.22091: . ack 2083 win
> 11680
> E..(..@.@..[
> ....dR .@VK....}D..P.-.'...
>
> Could it be that the traffic is not being recognized as tcp type
> traffic? I am also wondering if there is some sort of limit in iptables
> causing it to somehow bomb out before the final drop line is reached. In
> reality my allow list has some 2000 or so British networks listed (taken
> from http://www.countryipblocks.net). The list appears to be complete if
> I do iptables -L -n. This lists shows all the networks, and tne final
> drop line, so I know that my script is populating iptables.
>
> I am performing further tests.
>
> Regards,
>
> Mark.


That is an interesting site Mark. The only flaw in the plan is most
attackers use a chain of proxies and bypass this kind of filtering.


--
begin oefixed_in_2005.exe
Reply With Quote
  #16 (permalink)  
Old 07-05-2008, 11:08 AM
Mark Hobley
 
Posts: n/a
Re: iptables: allowing only listed hosts to connect to a port

Klunk <bill.gates@microsoft.com> wrote:
> That is an interesting site Mark. The only flaw in the plan is most
> attackers use a chain of proxies and bypass this kind of filtering.


Yeah. I would like to see doornumber and postcode in all hostnames, so
that owners of compromised machines could be notified.

Mark.

--
Mark Hobley,
393 Quinton Road West,
Quinton, BIRMINGHAM.
B32 1QE.
Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Linux > Linux Networking


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:42 AM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Gas Suppliers | Loans | Loan | Credit Cards | Secured Loans



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114