Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
When you forward port P of host H to port Q of host I, you actually listen on H:P and send (forward) any packets to I:Q, and you also send any response packets you get from I back to the client (whoever initiated the connection). It follows that port P on H must be free, and if P<1024, you need to be(come) root on H.
Quote:
and gimme some tutorials or guides related to that...
Others provided tutorials.
The easiest way to temporarily forward ports is using the -L or -R option of ssh. For a trivial example,
listen on H:P and send (forward) any packets to I:Q
what does this syntax means... H:P and I:Q...port P on host H and port Q on host I ?? or does it have any other meaning...and say i am in LAN and i want to send packets from my port say "x" to my friends PC port say "y"... how to achieve this.....is this also IP forwarding...
H:P and I:Q...port P on host H and port Q on host I ??
Yes, exactly. For example, the HTTP port (port 80) of host google.com (72.14.207.99 among others) is often denoted "google.com:80" or "2.14.207.99:80". It's just a convention/shorthand.
Quote:
and say i am in LAN and i want to send packets from my port say "x" to my friends PC port say "y"... how to achieve this...
Answer A: You have to tell us (much) more. What are you trying to achieve? Are you sure you need to think at the packet level, or could you describe your goal in terms of a "connection"?
Answer B: nc
Hint: the originating port (x) hardly ever matters.
Quote:
is this also IP forwarding...
If I understand you right, it isn't -- it's just some packets (and maybe a connection) between you and your friend. The machine doing IP forwarding (H in my example) in a way acts as a proxy between a client and a server (I).
I neglected to mention that with ssh, the listening side and the forwarding/initiating side can be on different computers, which lets you tunnel through firewalls. That's a bit different from "plain" forwarding.
BTW, there's a fairly simple perl script out on the web for connection forwarding.
Thanks Quigi,
what i had thought from your explanation in the first reply is the host itself is the client ...now i got your point... u mean to say IP forwarding is same as IP masquerading ??
Quote:
ssh -L 8000:google.com:80 localhost
what exactly this does.. i didnt get.. sorry...
Quote:
The machine doing IP forwarding (H in my example) in a way acts as a proxy between a client and a server (I).
can u please gimme an example considering 3 machines with conditions... to understand IP forwarding better...
thanks again....
Please disregard everything I said about port forwarding, because you had asked about IP forwarding. I tried http://en.wikipedia.org/wiki/Special.../IP_forwarding (their search failed temporarily, but Google got me some hits.)
Quote:
can u please gimme an example considering 3 machines with conditions... to understand IP forwarding better...
Say you browse to www.google.com; let's look in minute detail what goes on.
Host A (your computer) wants to send a packet to host B (say, www.google.com). As route -n reveals, A doesn't have a direct wire to B, so it sends the packet to the appropriate gateway C (marked with a G in the "Flags" column, probably your default gateway). Now machine C acts as a router and forwards the packet to another machine, which is one hop closer to B. Here, C does IP forwarding. Note that this is just the beginning -- there are many more steps till your packet gets to B, and a response packet makes its way back to A (probably again through C), and then many more packet roundtrips till (a fraction of a second later) your browser displays the google page.
Thanks Quigi,
i am just trying to get a clear picture and understand between IP forwarding IP masquerading and port forwarding...
Quote:
A doesn't have a direct wire to B, so it sends the packet to the appropriate gateway C
...
u r telling something about packets... i think this is regarding connections right ??
here what is the meaning of sending packets ?? because when establishing any conneciton packets will obviously come into picture right ?? what is special here ??
Quote:
Here, C does IP forwarding.
IT DOES IP FORWARDING... how it does ???
sorry if i am bugging u tooo much....i am really trying to understand the things better....
For getting an overall picture, keep reading the web. I found the articles in Wikipedia particularly helpful and well-written.
When establishing, using, and tearing down a connection, packets are exchanged. (But you may also send around packets (e.g., UDP datagrams) without establishing a connection.) Packets and connections are talking at different levels of the ISO/OSI model.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.