The above example lets any port 1024 and up from host 10.1.1.2 to pass thorugh to host 10.1.1.2 port 3306
Main Topics
Browse All TopicsI am running Redhat ES 4 Update 5 with the firewall enabled.
I am installing the Oracle Application server. It has a number of ports that have to be opened to communicate with the internet. One service in particular, Oracle Reports server, looks for a specific IP address and Port.
I know how to open up specific ports for communication via an iptables rule. But how do you allow communication from and to a specific IP address and Port? I haven't been able to find this specific information and I have been scouring the internet.
Thanks,
Tony
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hello Leon,
I have entered the following, but it does not seem to work:
iptables -A INPUT -p tcp -s 192.168.2.151 --sport 7778:7788 -d 228.5.6.7 --dport 14021:14030 -m state --state NEW,ESTABLISHED -j ACCEPT
I am not sure what I am doing wrong, but I want to allow traffic from 192.168.2.151:7778 through to 228.5.6.7:14021 to begin with and there will be other ports on these hosts later. But that is for starters. If I understood your instructions, this should work. Hmmm...
Please let me know what I am doing wrong.
Thanks,
Anthony
when you want bidirectional traffic, maybe you need two rules:
LOCALIP=1.1.1.1
REMOTEIP=2.2.2.2
LOCALPORT=3333
REMOTEPORT=4444
#allow from the other server to this one:
iptables -A INPUT -s $REMOTEIP -p tcp --sport $REMOTEPORT --dport $LOCALPORT -j ACCEPT
now go to the other server and allow traffic from this one:
LOCALIP=2.2.2.2
REMOTEIP=1.1.1.1
LOCALPORT=4444
REMOTEPORT=3333
iptables -A INPUT -s $REMOTEIP -p tcp --sport $REMOTEPORT --dport $LOCALPORT -j ACCEPT
Thank you everyone for all of your input. The rule that finally worked for me was this:
iptables -I RH-Firewall-1-INPUT -s 192.168.2.105 -p tcp --dport 5901 -j ACCEPT
This exclusively restricts traffic to port 5901 (vncserver's default port) from IP 192.168.2.105. All others will never see it or get a response.
FYI, You can also mask the IP address like this:
iptables -I RH-Firewall-1-INPUT -s 192.168.2.0/8 -p tcp --dport 5901 -j ACCEPT
*OR*
iptables -I RH-Firewall-1-INPUT -s 192.168.0.0/16 -p tcp --dport 5901 -j ACCEPT
*OR*
iptables -I RH-Firewall-1-INPUT -s 192.0.0.0/24 -p tcp --dport 5901 -j ACCEPT
Business Accounts
Answer for Membership
by: leoneaganPosted on 2007-09-06 at 11:35:59ID: 19842614
iptables -A INPUT -p tcp -s 10.1.1.1 --sport 1024:65535 -d 10.1.1.2 --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT