Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 04-29-2003, 11:37 AM   #1
LQ Newbie
Registered: Apr 2003
Distribution: RedHat 8.0 - Kernel 2.4.20-8
Posts: 28

Rep: Reputation: 15
iptables - source ? destination ? From where ?

Hi !

the question will sound stupid but in iptables, what is the point of reference for the "source" and "destination" feature.

I mean, you have your computer and internet.
You set
Accept packet if destination port is tcp 80.
Does it mean allow the packet that goes from my computer to internet on tcp 80
allow the packet that goes from internet to my computer on port tcp 80 ?

Thanks in advance !

Old 04-29-2003, 12:26 PM   #2
LQ Veteran
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 416Reputation: 416Reputation: 416Reputation: 416Reputation: 416
The effect of source and destination will vary depending whether it is in the INPUT or the OUTPUT chain. Just as an example, I allow FTP connections from within my LAN only and I use blocks on both chains. So on the INPUT chain I've got

iptables -A INPUT -p tcp -s --dport 21 -j ACCEPT

In this case the rule only allows FTP if the source is and it is heading to port 21 on my linux box. That could be modified to

iptables -A INPUT -p tcp -s --sport 21 -j ACCEPT

in which case the traffic would be allowed only if it was coming from port 21 on one of my lan computers.

And then on the OUTPUT chain I've got

iptables -A OUTPUT -p tcp -d --sport 21 -j ACCEPT

In this case the FTP connection is allowed only if it is going to my lan and it is coming from port 21 on my linux box. You could also do something like:

iptables -A OUTPUT -p tcp -d ---dport 21 -j ACCEPT

in which case any traffic heading for port 21 on any machine on the lan would be allowed regardless of what port on the linux box is originating the connection.
1 members found this post helpful.
Old 04-29-2003, 02:50 PM   #3
LQ Newbie
Registered: Apr 2003
Distribution: RedHat 8.0 - Kernel 2.4.20-8
Posts: 28

Original Poster
Rep: Reputation: 15
Thanks Hangdog42 ! I will keep your clear answer to refer each time i get a doubt on the question.

Thanks to you things start to make some sense with iptables.

Old 04-30-2003, 11:43 PM   #4
LQ Newbie
Registered: Apr 2003
Posts: 18

Rep: Reputation: 0
Basically you allow traffic from your computer to the internet, if you want to browse over the internet and you allow traffic from the internet to tcp port 80 if you a web pages in your LAN.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Change the destination URL by IPTABLES swmok Linux - Networking 4 09-14-2004 11:33 AM
iptables logging destination Strikeman Linux - Security 1 03-12-2004 12:45 PM
problem to print source address and destination address jooboo Programming 2 11-26-2003 03:24 PM
IPTABLES --to-destination muliple ip:port hawk4eye Linux - Networking 4 02-07-2003 04:59 AM
Martion Source/Destination bfloeagle Linux - Networking 2 06-13-2001 06:42 AM

All times are GMT -5. The time now is 09:17 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration