LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 09-21-2010, 09:23 PM   #1
willcastle
Member
 
Registered: Sep 2010
Location: Philippines
Distribution: Centos
Posts: 63

Rep: Reputation: 0
enabling ports


HI,

how do i enable or open port in the iptables?

thank you and God bless.
 
Old 09-21-2010, 09:30 PM   #2
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by willcastle View Post
HI,

how do i enable or open port in the iptables?

thank you and God bless.
To open a port you need to have something listen on it. That's not something iptables does. If, OTOH, what you mean is "How do I allow packets with a certain destination port?" or similar, an example could be:
Code:
iptables -A INPUT -p TCP --dport 123 -j ACCEPT
 
Old 09-21-2010, 09:36 PM   #3
krishnakant
LQ Newbie
 
Registered: May 2009
Location: Chennai
Distribution: CentOS, RHEL and fedora
Posts: 22

Rep: Reputation: 0
You can set rules to open port in IPTABLES.

Please follow below mention links:
http://www.cyberciti.biz/faq/iptables-open-ftp-port-21
http://www.linuxhomenetworking.com/w...Using_iptables


iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d 202.54.1.20 --dport 21 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s 202.54.1.20 --sport 21 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT


Hope these are helpful for you.

Thanks,
Krishna Kant
Linux System Engineer
 
Old 09-21-2010, 09:40 PM   #4
willcastle
Member
 
Registered: Sep 2010
Location: Philippines
Distribution: Centos
Posts: 63

Original Poster
Rep: Reputation: 0
Okay. How about opening ports 110 and 25?

Thanks and God Bless.
 
Old 09-21-2010, 09:44 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 willcastle View Post
Okay. How about opening ports 110 and 25?

Thanks and God Bless.
To open those ports you need to start a daemon which listens on them. Simply creating iptables rules for those ports won't open them - they will still be closed unless something is actually listening on them. As for the iptables rules to allow packets with those destination ports, just change the 123 in my example to 110, then execute a second command with a 25 instead of a 123. Like:
Code:
iptables -A INPUT -p TCP --dport 110 -j ACCEPT
iptables -A INPUT -p TCP --dport 25 -j ACCEPT
There's also a multiport match module you can use if you wanna knock it all out in one command. Example:
Code:
iptables -A INPUT -p TCP -m multiport --dports 110,25 -j ACCEPT

Last edited by win32sux; 09-21-2010 at 09:45 PM.
 
Old 09-21-2010, 09:45 PM   #6
willcastle
Member
 
Registered: Sep 2010
Location: Philippines
Distribution: Centos
Posts: 63

Original Poster
Rep: Reputation: 0
Hi,

My distro is CentOS, and I need to open ports 110 and 25.

Where will I locate the iptables and how do I configure it?

Thanks and God Bless.

William
 
Old 09-21-2010, 09:50 PM   #7
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by willcastle View Post
Hi,

My distro is CentOS, and I need to open ports 110 and 25.

Where will I locate the iptables and how do I configure it?

Thanks and God Bless.

William
Please post the output of these commands:
Code:
netstat -an --inet | grep LISTEN
Code:
iptables -nvL --line-numbers
 
Old 09-21-2010, 09:55 PM   #8
willcastle
Member
 
Registered: Sep 2010
Location: Philippines
Distribution: Centos
Posts: 63

Original Poster
Rep: Reputation: 0
Code:
netstat -an --inet | grep LISTEN
tcp        0      0 0.0.0.0:993                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:995                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:110                 0.0.0.0:*                   LISTEN
tcp        0      0 127.0.0.1:783               0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:143                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:606                 0.0.0.0:*                   LISTEN
Code:
iptables -nvL --line-numbers

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

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

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination
That's the output.

Thanks.

Last edited by win32sux; 09-21-2010 at 09:56 PM. Reason: Added CODE tags for readability.
 
Old 09-21-2010, 10:00 PM   #9
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by willcastle View Post
Code:
netstat -an --inet | grep LISTEN
tcp        0      0 0.0.0.0:993                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:995                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:110                 0.0.0.0:*                   LISTEN
tcp        0      0 127.0.0.1:783               0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:143                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:606                 0.0.0.0:*                   LISTEN
You have daemons listening on 110/TCP and 25/TCP.

Quote:
Code:
iptables -nvL --line-numbers

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

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

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination
You have no firewall rules active.

The two observations above indicate that the ports are already in an open state.

This should be easy to confirm from a remote box with an Nmap scan.

Last edited by win32sux; 09-21-2010 at 10:02 PM.
 
Old 09-21-2010, 10:02 PM   #10
willcastle
Member
 
Registered: Sep 2010
Location: Philippines
Distribution: Centos
Posts: 63

Original Poster
Rep: Reputation: 0
Chain INPUT (policy ACCEPT 918 packets, 76190 bytes)
num pkts bytes target prot opt in out source destination
1 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:110
2 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:25

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

Chain OUTPUT (policy ACCEPT 264 packets, 29987 bytes)
num pkts bytes target prot opt in out source destination

This is now the output.

Thanks.
 
Old 09-21-2010, 10:03 PM   #11
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by willcastle View Post
Chain INPUT (policy ACCEPT 918 packets, 76190 bytes)
num pkts bytes target prot opt in out source destination
1 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:110
2 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:25

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

Chain OUTPUT (policy ACCEPT 264 packets, 29987 bytes)
num pkts bytes target prot opt in out source destination

This is now the output.

Thanks.
That doesn't change anything. Like I said, the packets were already being allowed. You only need to mess with iptables if you're looking to add certain restrictions, which isn't the case here AFAICT.

Last edited by win32sux; 09-21-2010 at 10:04 PM.
 
Old 09-21-2010, 10:05 PM   #12
willcastle
Member
 
Registered: Sep 2010
Location: Philippines
Distribution: Centos
Posts: 63

Original Poster
Rep: Reputation: 0
What seems to be problem sir?

Is it a Firewall problem?
Thanks.

Last edited by willcastle; 09-21-2010 at 10:06 PM.
 
Old 09-21-2010, 10:11 PM   #13
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by willcastle View Post
What seems to be problem sir?

Is it a Firewall problem?
Thanks.
There's no problem AFAICT. You were looking for iptables commands to allow you to use ports 110 and 25. After posting your iptables configuration, it became evident that you don't need any iptables rules to allow access to those ports, since you have no current rules preventing access to them. In other words, iptables will by default refrain from doing any packet filtering, so unless you've changed the default configuration (which apparently you haven't) there really isn't anything for you to do unless you want to start doing packet filtering.

You've got daemons listening on 110 and 25. You've got iptables configured to allow all packets. You're pretty much set as far as your stated desires are. We're here to help if you decide to implement some filtering but as far as your question is concerned there honestly isn't anything to do. Perhaps you can explain what exactly you're having trouble with? Is it that you can't connect to the daemons from a remote box? If so, please provide a description of the setup, both physically (switches, routers, etc.) and logically (IP configurations, etc.), as well as the troubleshooting steps you've taken thus far (and the results).

Last edited by win32sux; 09-21-2010 at 10:14 PM.
 
Old 09-21-2010, 10:23 PM   #14
willcastle
Member
 
Registered: Sep 2010
Location: Philippines
Distribution: Centos
Posts: 63

Original Poster
Rep: Reputation: 0
Okay.

My configuration is:

Router:222.127.x.x
|
Firewall is Pfsense:192.168.101.1
|
email server: 192.168.101.5

Pardon my decription, honestly I don't know how to.
 
Old 09-21-2010, 11:13 PM   #15
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by willcastle View Post
Okay.

My configuration is:

Router:222.127.x.x
|
Firewall is Pfsense:192.168.101.1
|
email server: 192.168.101.5

Pardon my decription, honestly I don't know how to.
Okay, but you haven't really told us what the problem is. Is it that you're unable to see the ports as being open from the WAN side of 222.127.x.x? How are you verifying? That could be an issue with 222.127.x.x and/or 192.168.101.1 (mis-configured port forwarding, for example). As for 192.168.101.5, we know the daemons are listening and the firewall is disabled, so the only other basic thing to check would be the IP configuration. We can have a look if you post the output of:
Code:
route -n
Code:
ifconfig
BTW, I'm moving this to Networking for more adequate exposure.

Last edited by win32sux; 09-21-2010 at 11:14 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
enabling ports for certain apps cjae SUSE / openSUSE 1 11-28-2005 12:20 AM
enabling ports on iptables deley71 Red Hat 1 07-14-2004 02:54 PM
Enabling ports for samba toadoy Linux - Newbie 3 07-08-2004 06:35 AM
Enabling telnet on other ports guinnyn Linux - Networking 0 08-22-2003 07:49 PM
enabling ports! chris Linux - General 7 11-19-2002 05:49 PM

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

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