On Thu, 12 Jun 2008 12:56:40 +0100, Andy Furniss
<(E-Mail Removed)> wrote:
>Bob Simon wrote:
>
>> Andy,
>> Thank you for your comments. The Windows Firewall setting is off for
>> this interface. Later today I will try to find an old ethernet hub
>> (repeater) and use wireshark to capture and decode traffic. As you
>> suggested, this should help isolate the problem.
>
>tcpdump on eth1 should see what has already made it through lan bound as
>it sees the traffic closer to the wire than iptables.
>
>>
>> In the mean time, I'm very interested in learning if my firewall rules
>> are keeping uTorrent from making the required connections -- not for
>> this uTorrent issue, but because I want to be sure I know how to
>> manage my firewall. So I've included the whole (sanitized) firewall
>> config file below. I welcome any suggestions you might make.
>
>I may not be the best person to comment - my firewall is very simple,
>based on Rusty Russels example in a doc on the netfilter site.
>
Mine too.
>>
>> eth0 is the outside interface and eth1 is inside. The machine running
>> uTorrent is $bob1. 192.168.1.0 is my wireless network. 6881-6889 are
>> the default torrent ports but the counts on these are zero so these
>> statements are apparently useless -- I will remove them after I get
>> uTorrent working properly. Perhaps I should also mention that I'm
>> running an old version of linux and iptables -V shows "iptables
>> v1.2.7a".
>>
>> Finally, please explain why you say:
>>> If eth0 is wan and a different nic is lan you should really add -i eth0
>>> to the DNAT rules.
>> Won't stateful inspection handle the translation of return packets
>> automatically?
>
>Nothing to do with return packets, it's just being more specific. If you
>wanted to, you should be able to access your box from the lan side using
>the wan ip address (addresses are not really bound to nics, but owned by
>the box) and that would be broken.
I did not know that the address was not bound to the interface. The
reverse is true for all the routers that I've worked with.
I'm still a little hazy regarding adding eth0 to the DNAT rules. It
may help me understand your point if you posted this entire rule. Are
you saying that this would enable packets whose destination IP address
is eth0 to be NATed and forwarded to the inside? If I understand
this correctly, it seems that it would open up all the inside machines
to potential attack.
>
>>
>> Here's the entire config:
>>
>> global=xx.xx.xx.xx
>> bob1=192.168.0.2
>> bob2=192.168.1.9
>>
>> echo 1 > /proc/sys/net/ipv4/ip_forward
>> iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
>> iptables -t nat -A PREROUTING -p tcp -d $global --dport 6881:6889 -j
>> DNAT --to $bob1
>> iptables -t nat -A PREROUTING -p tcp -d $global --dport 31234 -j DNAT
>> --to $bob1
>> iptables -t nat -A PREROUTING -p udp -d $global --dport 31234 -j DNAT
>> --to $bob1
>>
>> iptables -P INPUT DROP
>> iptables -A INPUT -p tcp --dport ssh -i eth1 -s $bob1 -j ACCEPT
>> iptables -A INPUT -p tcp --dport ssh -i eth1 -s $bob2 -j ACCEPT
>> iptables -A INPUT -p icmp -i eth1 -j ACCEPT
>> # Remove following comment to allow return packets (normal operation)
>> # iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT
>> iptables -A INPUT -p tcp --dport ssh -m limit --limit-burst 2 --limit
>> 2/day -j LOG --log-prefix "Invalid SSH "
>>
>> iptables -P FORWARD DROP
>> iptables -A FORWARD -i eth0 -s 192.168.0.0/16 -j LOG --log-prefix
>> "Bad IP "
>> iptables -A FORWARD -i eth0 -s 192.168.0.0/16 -j DROP
>> iptables -A FORWARD -i eth0 -s 10.0.0.0/8 -j LOG --log-prefix "Bad IP
>> "
>> iptables -A FORWARD -i eth0 -s 10.0.0.0/8 -j DROP
>> iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
>> iptables -A FORWARD -m state --state NEW -i ! eth0 -j ACCEPT
>> # following commands are for uTorrent
>> iptables -A FORWARD -d $bob1 -p tcp --dport 31234 -j ACCEPT
>> iptables -A FORWARD -d $bob1 -p udp --dport 31234 -j ACCEPT
>> iptables -A FORWARD -d $bob1 -p tcp --dport 6881:6889 -j ACCEPT
>
>I can't spot anything that should stop utorrent up to here. I suppose
>its connectivity test may use ICMP or something so it shows a fail
>because that gets blocked or maybe it expects upnp to be working. I've
>never used it, but do manage to use Linux torrent/p2p with rules the
>similar to these. The difference being I use -m state --state NEW as well.
Good points. Thanks.
>> iptables -A FORWARD -m limit --limit-burst 2 --limit 4/day -j LOG
>> --log-prefix "New Pkt "
>>
>> # iptables -I OUTPUT -j LOG --log-prefix "Out "
>>
>> # Syn-flood protection
>> iptables -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT
>> #Furtive port scanner
>> iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit
>> --limit 1/s -j ACCEPT
>> #Ping of death
>> iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit
>> 1/s -j ACCEPT
>>
>
>Given you are doing nat I don't think much will make it to here, but if
>it did/does the really low limit,lack of burst on the syn-flood would
>mess things up for you.
Thanks for your comments. I will fix this.
>Andy.
Bob
|