Re: iptables: cannot talk to localhost

From: David (davidwnh_at_adelphia.net)
Date: 12/30/03


Date: Tue, 30 Dec 2003 07:28:34 GMT

Is your host file correct?

Any how this is not a good way to allow loopback traffic. You are
allowing packets from any interface to use a spoofed localhost source
address to pass your firewall. You also need to allow your own IP
addresses to talk to the loopback for certain things.

Try something like:
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
In other words specify the adapter in which you are allowing it.
>
> # Allow all loopback
> iptables -A INPUT -s localhost -j ACCEPT
> iptables -A OUTPUT -d localhost -j ACCEPT
>

You also want to jump elsewhere to look for spoofs. Best used with
connection tracking so you only have to check the initial packets and
not every packet in a session.

iptables -A INPUT -i eth0 -j source-address-check
  Within your source-address-check chain you can append rules to look
for your own address being spoofed as well as the loopback, private
network addresses, and if you wish broadcast and multicast addresses.

These FTP rules allow for a total compromise of your firewall and
possibly machine. A hacker simply has to specify his scanning then
hacking tool to use port 20 or 21 as the source address. That
effectively bypasses your firewall for a complete scan and if you have a
service listening for which he/she knows a crack....Game over....unless
you have a properly configured firewall or cable/dsl router in front of
this machine.

> # FTP:
> iptables -A INPUT -p tcp --sport 20:21 -j ACCEPT
> iptables -A INPUT -p udp --sport 20:21 -j ACCEPT
> iptables -A OUTPUT -p tcp --dport 20:21 -j ACCEPT
> iptables -A OUTPUT -p udp --dport 20:21 -j ACCEPT
>

Same thing for several of your other rules.

> # HTTP:
> iptables -A INPUT -p tcp --sport 80 -j ACCEPT
> iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT
>
>
> # HTTPS:
> iptables -A INPUT -p tcp --sport 443 -j ACCEPT
> iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT
>
> # MSN Messenger:
> iptables -A INPUT -p tcp --sport 1863 -j ACCEPT
> iptables -A INPUT -p tcp --sport 6891:6900 -j ACCEPT
> iptables -A OUTPUT -p tcp --dport 1863 -j ACCEPT
> iptables -A OUTPUT -p tcp --dport 6891:6900 -j ACCEPT
>
> # AOL:
> iptables -A INPUT -p tcp --sport 5190 -j ACCEPT
> iptables -A OUTPUT -p tcp --dport 5190 -j ACCEPT
>
> # Yahoo:
> iptables -A INPUT -p tcp --sport 5050 -j ACCEPT
> iptables -A OUTPUT -p tcp --dport 5050 -j ACCEPT
> iptables -A INPUT -p tcp --sport 5000:5001 -j ACCEPT
> iptables -A OUTPUT -p tcp --dport 5000:5001 -j ACCEPT
>
> # IRC (chat):
> iptables -A INPUT -p tcp --sport 6667 -j ACCEPT
> iptables -A OUTPUT -p tcp --dport 6667 -j ACCEPT
>
> # Shoutcast
> iptables -A INPUT -p tcp --sport 8888 -j ACCEPT
> iptables -A OUTPUT -p tcp --dport 8888 -j ACCEPT
>
>



Relevant Pages

  • Re: iptables and dhcp
    ... > the same physical network segment as the firewall and the remote DHCP ... You used INPUT and not FORWARD chain ... # This target allows packets to be marked in the mangle table ...
    (comp.os.linux.networking)
  • Re: Trouble accessing Outlook Web Access from behind firewall
    ... When starting the firewall I also set ... > rejected and dropped packets are logged, however I see nothing in my log ... > # Higher ports needed to accept incoming/outgoing calls ...
    (comp.security.firewalls)
  • Re: Visnetic and 8signs firewall LOOPHOLE Read....
    ... I said I am just reporting bug in your Firewall, ... From the Port Scan/Properties control screen: ... The firewall filtered 100% of the packets that were received. ... operating system (I'm talking Windows, ...
    (comp.security.firewalls)
  • Re: strange network traffic
    ... Maybe not so wise to not have a firewall and trust a third party lurker to ... Subject: strange network traffic ... > -> connection established, following packets have neither SYN nor ...
    (Security-Basics)
  • Re: port 80 is open
    ... The firewall drops all packets initiated ... > internet the ISP router does not send the unreachable message. ... and then close the connection as your IP is seen as not connected. ...
    (comp.security.firewalls)