LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 01-21-2009, 04:14 AM   #1
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Rep: Reputation: 70
Question Incomprehensible Iptables; Firewall Blocks Everything!


Hi guys,

I'm having difficulty with reading iptable rules. I've evidently configured something wrong in the "UFW" and/or "Lokkit" settings, because no traffic seems to be able to get through. I've appended the output of "iptables -L" below. I can't understand a word of it, I'm afraid.

My aims are pretty simple:

I'm connecting via usb stick modem to the Vodafone mobile network

The box is a stand-alone desktop, single-user, running Ubuntu 8.1; no server requirements; no SSH etc.

I just want to close off everything except Web browsing, file downloading (torrent & ftp) and system updates.


Here's the output from "iptables -L"


Chain INPUT (policy DROP)
target prot opt source destination
RH-Lokkit-0-50-INPUT all -- anywhere anywhere
ufw-before-input all -- anywhere anywhere
ufw-after-input all -- anywhere anywhere

Chain FORWARD (policy DROP)
target prot opt source destination
RH-Lokkit-0-50-INPUT all -- anywhere anywhere
ufw-before-forward all -- anywhere anywhere
ufw-after-forward all -- anywhere anywhere

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ufw-before-output all -- anywhere anywhere
ufw-after-output all -- anywhere anywhere

Chain RH-Lokkit-0-50-INPUT (2 references)
target prot opt source destination
ACCEPT udp -- anywhere anywhere udp spts:bootps:bootpc dpts:bootps:bootpc
ACCEPT udp -- anywhere anywhere udp spts:bootps:bootpc dpts:bootps:bootpc
ACCEPT all -- anywhere anywhere
REJECT tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN reject-with icmp-port-unreachable
REJECT udp -- anywhere anywhere udp reject-with icmp-port-unreachable

Chain ufw-after-forward (1 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix `[UFW BLOCK FORWARD]: '
RETURN all -- anywhere anywhere

Chain ufw-after-input (1 references)
target prot opt source destination
RETURN udp -- anywhere anywhere udp dpt:netbios-ns
RETURN udp -- anywhere anywhere udp dpt:netbios-dgm
RETURN tcp -- anywhere anywhere tcp dpt:netbios-ssn
RETURN tcp -- anywhere anywhere tcp dpt:microsoft-ds
RETURN udp -- anywhere anywhere udp dpt:bootps
RETURN udp -- anywhere anywhere udp dpt:bootpc
RETURN all -- anywhere anywhere ADDRTYPE match dst-type BROADCAST
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix `[UFW BLOCK INPUT]: '
RETURN all -- anywhere anywhere

Chain ufw-after-output (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere

Chain ufw-before-forward (1 references)
target prot opt source destination
ufw-user-forward all -- anywhere anywhere
RETURN all -- anywhere anywhere

Chain ufw-before-input (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
DROP all -- anywhere anywhere ctstate INVALID
ACCEPT icmp -- anywhere anywhere icmp destination-unreachable
ACCEPT icmp -- anywhere anywhere icmp source-quench
ACCEPT icmp -- anywhere anywhere icmp time-exceeded
ACCEPT icmp -- anywhere anywhere icmp parameter-problem
ACCEPT icmp -- anywhere anywhere icmp echo-request
ACCEPT udp -- anywhere anywhere udp spt:bootps dpt:bootpc
ufw-not-local all -- anywhere anywhere
ACCEPT all -- 224.0.0.0/4 anywhere
ACCEPT all -- anywhere 224.0.0.0/4
ufw-user-input all -- anywhere anywhere
RETURN all -- anywhere anywhere

Chain ufw-before-output (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere state NEW,RELATED,ESTABLISHED
ACCEPT udp -- anywhere anywhere state NEW,RELATED,ESTABLISHED
ufw-user-output all -- anywhere anywhere
RETURN all -- anywhere anywhere

Chain ufw-not-local (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere ADDRTYPE match dst-type LOCAL
RETURN all -- anywhere anywhere ADDRTYPE match dst-type MULTICAST
RETURN all -- anywhere anywhere ADDRTYPE match dst-type BROADCAST
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix `[UFW BLOCK NOT-TO-ME]: '
DROP all -- anywhere anywhere

Chain ufw-user-forward (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere

Chain ufw-user-input (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere

Chain ufw-user-limit (0 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 5 LOG level warning prefix `[UFW LIMIT]: '
REJECT all -- anywhere anywhere reject-with icmp-port-unreachable

Chain ufw-user-limit-accept (0 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere

Chain ufw-user-output (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere

Can anyone spot what's wrong from the above?

Thanks,

CC.
 
Old 01-21-2009, 09:37 AM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by Completely Clueless
My aims are pretty simple:

I'm connecting via usb stick modem to the Vodafone mobile network

The box is a stand-alone desktop, single-user, running Ubuntu 8.1; no server requirements; no SSH etc.

I just want to close off everything except Web browsing, file downloading (torrent & ftp) and system updates.
Given your requirements, the ruleset you posted is complex and bizarre.

Try this from the command line instead:
Code:
# iptables -P INPUT ACCEPT
# iptables -F
# iptables -A INPUT -i lo -j ACCEPT 
# iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT 
# iptables -A INPUT -j DROP
Then save that ruleset - however it is Ubuntu saves rulesets. If you're still having trouble, post the output of iptables -nvL (in code tags).
 
Old 01-21-2009, 11:53 AM   #3
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Okay, thanks for that. I'll try it and report back shortly. I'm just re-installing Ubuntu from scratch just to make certain everything is nice and clean again.
 
Old 01-21-2009, 01:01 PM   #4
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Well the commands went in without complaint from the shell. Is the machine now protected? If so I can save the changes with "sudo iptables-save > /etc/default" which I believe is the correct place within Ubuntu.


Here's the output from # iptables -L......

Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere
DROP all -- anywhere anywhere state RELATED,ESTABLISHED

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

(END)


......and here's the output from # iptables -nvL.....

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination

Chain OUTPUT (policy ACCEPT 40 packets, 3184 bytes)
pkts bytes target prot opt in out source destination

(END)
 
Old 01-21-2009, 01:38 PM   #5
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by Completely Clueless View Post
Well the commands went in without complaint from the shell. Is the machine now protected? If so I can save the changes with "sudo iptables-save > /etc/default" which I believe is the correct place within Ubuntu.


Here's the output from # iptables -L......

Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere
DROP all -- anywhere anywhere state RELATED,ESTABLISHED

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

(END)


......and here's the output from # iptables -nvL.....

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination

Chain OUTPUT (policy ACCEPT 40 packets, 3184 bytes)
pkts bytes target prot opt in out source destination

(END)
I've never heard of a file called /etc/default. You can pretty much save your config to any file you wish, just specify the name of the file in a pre-up line in your /etc/network/interfaces file. For example, I store my firewall config in /etc/firewall.txt so my /etc/network/interfaces file looks like:
Code:
auto lo
iface lo inet loopback
pre-up iptables-restore < /etc/firewall.txt
That said, the configuration you've shown doesn't match the commands suggested by anomie. You are sending packages in states RELATED and ESTABLISHED to DROP, which would break all transmissions.

Last edited by win32sux; 01-21-2009 at 01:40 PM.
 
Old 01-21-2009, 02:43 PM   #6
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Hi Win32sux,

You're right. Mea Culpa.

I just double-checked and obviously mis-typed the suggested command first time round.

I've now re-entered the correct char.string put forward by anomie and the output text is now:

(BEGINS)

Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere
DROP all -- anywhere anywhere state RELATED,ESTABLISHED

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

(ENDS)

I have to say the terms employed by whomever wrote this program are deeply unhelpful inasmuch as they bear no relation to their generally-accepted meanings in the natural world. It's extremely confusing for those of us who read Victorian novels.

Anyway, am I clear to go online now? Is my box safe?

Thanks,

CC.
 
Old 01-21-2009, 02:43 PM   #7
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Hi Win32sux,

You're right. Mea Culpa.

I just double-checked and obviously mis-typed the suggested command first time round.

I've now re-entered the correct char.string put forward by anomie and the output text is now:

(BEGINS)

Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere
DROP all -- anywhere anywhere state RELATED,ESTABLISHED

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

(ENDS)

I have to say the terms employed by whomever wrote this program are deeply unhelpful inasmuch as they bear no relation to their generally-accepted meanings in the natural world. It's extremely confusing for those of us who read Victorian novels.

Anyway, am I clear to go online now? Is my box safe?

Thanks,

CC.
 
Old 01-21-2009, 03:27 PM   #8
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by Completely Clueless View Post
Hi Win32sux,

You're right. Mea Culpa.

I just double-checked and obviously mis-typed the suggested command first time round.

I've now re-entered the correct char.string put forward by anomie and the output text is now:

(BEGINS)

Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere
DROP all -- anywhere anywhere state RELATED,ESTABLISHED

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

(ENDS)

I have to say the terms employed by whomever wrote this program are deeply unhelpful inasmuch as they bear no relation to their generally-accepted meanings in the natural world. It's extremely confusing for those of us who read Victorian novels.

Anyway, am I clear to go online now? Is my box safe?

Thanks,

CC.
Actually, the output you've just posted still has the same problem.

If you execute his commands properly, your output should look like this (with different packet/byte counts):
Code:
win32sux@candystore:~$ sudo iptables -nvL INPUT
Chain INPUT (policy ACCEPT 25 packets, 10174 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
   33 15047 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
    0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0           
win32sux@candystore:~$

Last edited by win32sux; 01-21-2009 at 03:31 PM.
 
Old 01-22-2009, 05:51 AM   #9
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Quote:
Originally Posted by win32sux View Post
Actually, the output you've just posted still has the same problem.

If you execute his commands properly, your output should look like this (with different packet/byte counts):
Code:
win32sux@candystore:~$ sudo iptables -nvL INPUT
Chain INPUT (policy ACCEPT 25 packets, 10174 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
   33 15047 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
    0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0           
win32sux@candystore:~$
Thanks for that. I have re-entered the commands and now have the following output:-

(begins)

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination

Chain OUTPUT (policy ACCEPT 80 packets, 6368 bytes)
pkts bytes target prot opt in out source destination

(ends)

But with a policy of "ACCEPT 0 packets" of INPUT I can't see how this can possibly work?? Can it?
 
Old 01-22-2009, 05:59 AM   #10
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
As an aside, I think this is one area of the Ubuntu distro that Team Ubuntu needs to look into urgently if they hope to lure away more Windoze users. Iptables may certainly be a powerful, versatile and wonderfully precise way of tailoring your firewall needs, but user-friendly it CERTAINLY AINT!

I'm aware of add-ons like lokkit and ufw that simplify firewall rule-setting, but they're still crude and in need of further refinement - and they don't come with the distro so you have to download them, which is kinda risky with no operational firewall in the first place!!

I've no idea where to send suggestions for further development (I'm a Debian man, anyway) but the above is just my 2c worth.
 
Old 01-22-2009, 08:50 AM   #11
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
Quote:
Originally Posted by Completely Clueless View Post
I'm aware of add-ons like lokkit and ufw that simplify firewall rule-setting, but they're still crude and in need of further refinement - and they don't come with the distro so you have to download them, which is kinda risky with no operational firewall in the first place!!
O_o...

Downloading without a firewall from the repositories for the distribution is as safe as it gets and a firewall isn't going to protect you from anything bad that would come from those locations anyways.

I do not think a firewall does what you think a firewall does (excuse my princess bride butchery.)

Don't get me wrong-- a firewall is a very useful piece of technology to have between you and the internet. That being said a firewall on the local machine is largely moot if you're already NAT'd like most people on broadband. If you get a direct routeable internet ip on your computer it's considerably more useful of course.

My default install only has ssh showing to the outside even without a firewall, but I don't suppose most newbies strip things down that far to begin with. Shrug, YMMV.

Last edited by rweaver; 01-22-2009 at 12:36 PM.
 
Old 01-22-2009, 09:20 AM   #12
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Quote:
Originally Posted by rweaver View Post
O_o...

Downloading without a firewall from the repositories for the distribution is as safe as it gets and a firewall isn't going to protect you from anything bad that would come from those locations anyways.
I'm not worried about anything nasty coming from a respository, but all the while I'm connected to the internet as things stand with the box in question, *all* ports are open (the default condition for Ubuntu) so there's no protection from nasties coming in via Telnet, SSH, FTP and the rest of these access points!
 
Old 01-22-2009, 10:54 AM   #13
unixfool
Member
 
Registered: May 2005
Location: Northern VA
Distribution: Slackware, Ubuntu, FreeBSD, OpenBSD, OS X
Posts: 782
Blog Entries: 8

Rep: Reputation: 158Reputation: 158
Quote:
Originally Posted by Completely Clueless View Post
I'm not worried about anything nasty coming from a respository, but all the while I'm connected to the internet as things stand with the box in question, *all* ports are open (the default condition for Ubuntu) so there's no protection from nasties coming in via Telnet, SSH, FTP and the rest of these access points!
Unless you've a telnet, SSH and FTP service configured and running, those ports will show as closed. This is the reason why the first measure of hardening a box would be to disable all unneeded services....no listening services, no open ports.

Last edited by unixfool; 01-22-2009 at 01:21 PM.
 
Old 01-22-2009, 12:28 PM   #14
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
Quote:
Originally Posted by unixfool View Post
Unless you've a telnet, SSH and FTP service configured and running, those ports will show as closed. This is the reason why the first measure of hardening a box would be to disabled all unneeded services....no listening services, no open ports.
Agreed, but most newbies don't know and don't want to know anything about security period unfortunately.
 
Old 01-22-2009, 12:29 PM   #15
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
Quote:
Originally Posted by Completely Clueless View Post
I'm not worried about anything nasty coming from a respository, but all the while I'm connected to the internet as things stand with the box in question, *all* ports are open (the default condition for Ubuntu) so there's no protection from nasties coming in via Telnet, SSH, FTP and the rest of these access points!
If you have a strong password and root logins disabled (for the services you listed), there's really no "nasties" available that can do anything to you. Ports are only open if you have a daemon running and listening on that port... why would you have telnet, ftp, etc running if you're not using them?

I'd be more concerned with portmap exposed or something similar if I installed nfs than i would be with most distributions versions of ssh and ftp (provided of course my password wasn't something silly like "fred")

Besides, if you're nat'd already behind another device even if you installed every single service you could stuff on the box and had no security enabled what so ever and still didn't have a local firewall... people on the internet *still* couldn't hit a single one of them unless you statically mapped a port from your nat device (or UPNP'd one).

Last edited by rweaver; 01-22-2009 at 12:39 PM.
 
  


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
DNSBL blocks and iptables fukawi2 Linux - Networking 2 10-26-2008 06:57 PM
work firewall blocks ssh traffic c_mitulescu Linux - Networking 3 07-12-2006 01:44 PM
Firewall blocks Samba? IchBin Linux - Networking 1 06-11-2005 05:21 PM
SuSE 9.2 - firewall blocks internal network cannabuz Linux - Networking 0 01-17-2005 08:34 AM
Firewall blocks me from sending irc dcc. zer0python Linux - Networking 8 01-13-2004 09:06 PM

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

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