LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 07-06-2015, 10:48 PM   #1
morphix
Member
 
Registered: Nov 2007
Location: Newcastle, Australia
Distribution: Ubuntu, Debian, Arch
Posts: 53

Rep: Reputation: 15
Debian 8 - iptables - Weird behaviour


Hi Guys,

I have recently installed a new server with Debian 8 (previously been using Ubuntu and Debian 7).

I have added only 1 or 2 iptables rules on INPUT chain only, not FORWARD or OUTPUT and then added default DROP policy.

What i've found, for some reason i can ping an internal IP (eg. router, or another server) but i cannot ping anything externally nor connect either internal or external via http, dns, etc (hostname or IP).

The rules are (3rd all rule being, for lo interface):
Quote:
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT tcp -- 192.168.2.0/24 0.0.0.0/0 tcp dpt:22
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
I'm a little baffled by this behaviour and need some guidance.
 
Old 07-07-2015, 01:10 PM   #2
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Run the following command and then paste the paste the contents of the file.

Code:
 iptables-save > /etc/iptables.up.rules
 
Old 07-07-2015, 05:53 PM   #3
morphix
Member
 
Registered: Nov 2007
Location: Newcastle, Australia
Distribution: Ubuntu, Debian, Arch
Posts: 53

Original Poster
Rep: Reputation: 15
I should have done that first, but there it is:
Quote:
*filter
:INPUT DROP [26408:5102000]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [922:110412]
-A INPUT -s 192.168.2.0/24 -p tcp --dport 22 -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
COMMIT
As you can see, nothing is touching OUTPUT, but it seems to be getting blocked for some reason (except ping to LAN IPs)

Last edited by morphix; 07-07-2015 at 05:54 PM.
 
Old 07-08-2015, 11:09 AM   #4
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Hopefully your server only has one interface. If not the you need to add to the firewall rules which interface the rule should apply to. Looking at your rules you only allow a non-routed IP to your system via ssh.

Maybe you could give this a try

Code:
*filter
:INPUT DROP [26408:5102000]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [922:110412]
-A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
-A INPUT -m conntrack --ctstate NEW -s 192.168.2.0/24 -p tcp --dport 22 -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A OUTPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
-A OUTPUT -m conntrack --ctstate NEW -j ACCEPT 
COMMIT
Also check your routing table to ensure all your routes are correct;

Code:
route -n

Last edited by lazydog; 07-08-2015 at 11:10 AM.
 
1 members found this post helpful.
Old 07-08-2015, 11:09 PM   #5
morphix
Member
 
Registered: Nov 2007
Location: Newcastle, Australia
Distribution: Ubuntu, Debian, Arch
Posts: 53

Original Poster
Rep: Reputation: 15
Yes, at this point only SSH inbound from local network only inbound.

The odd thing, i'm not touching OUTPUT so i don't know why it would be blocking it.

This machine is single interface only.

The routing is correct, as if i do:
Code:
iptables -P INPUT ACCEPT
I get outbound traffic working again, which is bizarre.
 
Old 07-09-2015, 09:37 AM   #6
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Your rules were not/are not Stateful based. Which means while you allowed everything out you were only allowing 22 back in locally. By switching to Stateful (what I have supplied) your return traffic is allowed because of the ESTABLISHED,RELATED rule.
 
1 members found this post helpful.
Old 07-12-2015, 07:27 PM   #7
morphix
Member
 
Registered: Nov 2007
Location: Newcastle, Australia
Distribution: Ubuntu, Debian, Arch
Posts: 53

Original Poster
Rep: Reputation: 15
Thanks mate, this worked a dream.
 
Old 07-16-2015, 07:03 AM   #8
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Glad I could help. Please mark this thread as resolved.
 
  


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
Weird behaviour jim.thornton Linux - Newbie 10 10-22-2012 09:30 PM
[SOLVED] Weird behaviour of Debian, please help! codeman1234 Linux - Software 1 04-28-2012 04:54 PM
Weird net behaviour with Debian Lenny analian Linux - Networking 7 06-08-2007 05:28 PM
9.3 weird behaviour ????? bigjohn SUSE / openSUSE 9 07-06-2005 05:44 AM
Weird Apache behaviour ? zalmox Linux - Software 1 11-10-2003 08:12 AM

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

All times are GMT -5. The time now is 08:16 PM.

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