LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-09-2007, 09:10 AM   #1
Richtown
Member
 
Registered: Apr 2006
Location: Portsmouth
Distribution: CentOS & Ubuntu
Posts: 49

Rep: Reputation: 15
Question iptables & ssh


Hi, i currently have a gateway between the internet and private network with the following iptable rules.

iptables -P INPUT DROP
iptables -P OUTPUT DROP

iptables -P FORWARD ACCEPT


There are some problems with this, i cannot connect to the gateway via SSH or HTTP.
Ive tried these rule but with no luck.

iptables -A INPUT -p tcp --sport 22 -j ACCEPT
iptables -A INPUT -p udp --sport 22 -j ACCEPT
iptables -A INPUT -p tcp --sport 80 -j ACCEPT
iptables -A INPUT -p udp --sport 80 -j ACCEPT

Does anyone know the correct syntax so i can do this. I have an apache web server running on port 80 on the gateway. Would nice to be able to connect to it :-).

If i remove the rules I.E iptable -P INPUT/OUTPUT ACCEPT i can SSH & HTTP into my gateway.

Any ideas?

Thanks Rich
 
Old 05-09-2007, 09:12 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
22 is the destination port (dport), not the source port (sport)
 
Old 05-09-2007, 09:21 AM   #3
Richtown
Member
 
Registered: Apr 2006
Location: Portsmouth
Distribution: CentOS & Ubuntu
Posts: 49

Original Poster
Rep: Reputation: 15
tried that still not working.
 
Old 05-09-2007, 09:22 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
tried what... please give actual code etc...
 
Old 05-09-2007, 09:33 AM   #5
Richtown
Member
 
Registered: Apr 2006
Location: Portsmouth
Distribution: CentOS & Ubuntu
Posts: 49

Original Poster
Rep: Reputation: 15
I've tried, iptables -A INPUT -p tcp -i eth1 --dport 22 -j ACCEPT and the same with port 80.But this doesnt seem to work. My setup is shown below:

Internet :eth0 ====GATEWAY==== eth1: Local Area Network

Thanks,
 
Old 05-09-2007, 09:49 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
what's the full iptables list look like? obviosuly if you add that rule after a wider reject it'll have no benefit.
 
Old 05-09-2007, 09:51 AM   #7
Richtown
Member
 
Registered: Apr 2006
Location: Portsmouth
Distribution: CentOS & Ubuntu
Posts: 49

Original Poster
Rep: Reputation: 15
Question

The full iptables commands are:

iptables -F
iptables -P INPUT DROP
iptables -P FORWARD ACCEPT
iptables -P OUTPUT DROP


If i then run the following commands then i can gain access to the gateway?

Is this the only way to do it . . .
iptables -A INPUT -p tcp -i eth0 --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp -o eth0 --sport 22 -j ACCEPT
iptables -A INPUT -p tcp -i eth0 --sport 22 -j ACCEPT
iptables -A OUTPUT -p tcp -o eth0 --dport 22 -j ACCEPT


Seems a bit long winded?

Last edited by Richtown; 05-09-2007 at 09:53 AM.
 
Old 05-09-2007, 09:54 AM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
that's clearly not the whol list, as your commands your trying aren't listed there...

well you'd use connection tracking so you'd only have one entry per service, but that really isn't long winded at all.
 
Old 05-09-2007, 11:53 AM   #9
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
To get the full list (as it is actually used), try posting the output of “iptables-save”.
 
  


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
[SSH] Issue logging in [SSH & Permissions] MD3 Linux - Networking 11 12-10-2006 09:25 AM
[putty&ssh] Who is really good & expert in ssh https tunnelling and firewalling ? Xeratul Linux - General 12 12-03-2006 03:22 AM
SSH Port Forwarding with IPTables & DNAT MercurioBlue Linux - Networking 2 08-24-2006 11:17 PM
iptables & ssh Tezdread Linux - Networking 26 03-12-2003 03:01 AM
iptables & inbound ftp, ssh bddwyer Linux - Networking 3 02-06-2003 09:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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