How to access PC over router?

This is a discussion on How to access PC over router? within the Networking/Device Communication forums, part of the General Programming Boards category; Hi there! I am using TP-Link tl-740n wireless router. The problem is, that when ever I connect any device to ...

  1. #1
    Infant of C
    Join Date
    May 2010
    Location
    Karachi, Pakistan
    Posts
    118

    How to access PC over router?

    Hi there!
    I am using TP-Link tl-740n wireless router. The problem is, that when ever I connect any device to the router and look for the internet IP of the same, each and every device is showing the same IP address over the internet. Let suppose I have connect two PC's with the router PC A and B. Both have an internet IP let say 192.168.1.1. My question is, if I want to create a telnet connection (or any other type of TCP connection) with my PC A from some remote computer not in my LAN, what IP address should I use?

  2. #2
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,176
    O_o

    That's pretty much a consumer router's (IPV4) only purpose in life.

    You connect to the public IP. (This will be the IP address assigned to the router by your access company.)

    To connect to a specific computer, I invite you to read about "SSH Tunneling" (There are other possibilities, but that is relatively easy.) where you'd connect to the same IP and different port for every computer.

    Soma

  3. #3
    Infant of C
    Join Date
    May 2010
    Location
    Karachi, Pakistan
    Posts
    118
    Can you please be a bit clear. Actually I am not too good at networks....

  4. #4
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,649
    Read the router's User Guide, specifically the section on Port Forwarding. You need to set this up for each port you wish to traverse the firewall destined for a system inside your network.

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,449
    Just some clarification...
    There is private IP and public IP. 192.168.X.X are private IPs. There is and never will be a router or computer on the web which uses those IPs.
    As for connecting... you need port forwarding, as already mentioned. The reason is because several computers share the same IP, the router has no idea where to send the packets. So the idea is then that the router sends packets on port X to computer A and port Y to computer B, and so on. This process is called port forwarding. As for how to do it, well it depends on your router. So checking the router's manual is the best advice we can give.
    (No, we don't want to read through the manual to find how it's done for your model.)
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Infant of C
    Join Date
    May 2010
    Location
    Karachi, Pakistan
    Posts
    118
    Quite clear now! and thanks a lot... My router have an option of Virtual server under the heading of Forwarding. I think you are referring to it!
    Its description says:
    Virtual servers can be used for setting up public services on your LAN. A virtual server is defined as a service port, and all requests from Internet to this service port will be redirected to the computer specified by the server IP. Any PC that was used for a virtual server must have a static or reserved IP address because its IP address may change when using the DHCP function.
    Now one more question. The router is not allowing me to set same Internal port for multiple IP addresses of the LAN. Let say if both A & B are acting as TelNet servers, and both of them are listening at port 23. Router is not allowing me to set port 23 for [IP of A] and port 23 for [IP of B]

  7. #7
    Registered User
    Join Date
    Jun 2005
    Posts
    6,208
    A typical consumer router, if you have enabled port forwarding, only forwards requests to a specified machine. Forwarding an external request to multiple machines (or selecting an internal IP address from a number of alternatives, in order to service an external request) is beyond capability of the typical consumer router.

    Professional devices can be configured to do this, but typically cost significantly more (think an extra zero on the purchase price) than a consumer device.

    I'll leave out discussion of configuring a general-purpose computer (eg a PC) to function as a router. Difficulty of doing that depends on the host operating system on the PC, and choice of hardware, but it is the most flexible approach.
    Right 98% of the time, and don't care about the other 3%.

  8. #8
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,449
    Quote Originally Posted by C_programmer.C View Post
    Quite clear now! and thanks a lot... My router have an option of Virtual server under the heading of Forwarding. I think you are referring to it!
    Its description says:


    Now one more question. The router is not allowing me to set same Internal port for multiple IP addresses of the LAN. Let say if both A & B are acting as TelNet servers, and both of them are listening at port 23. Router is not allowing me to set port 23 for [IP of A] and port 23 for [IP of B]
    If you mean that the private port (ie, the port of the computer, not the port on the router), then there should be no problem having two computers listening on port 23 and forwarding different public ports to those private ip addresses, even if they use the same port.
    Otherwise remember that you can't use the same public port for both computers because then the router does not know where to forward the packet (without more advanced rules, as grumpy mentions).
    It may also be that it is an internal restriction of your router if you can't use the private port for two computers and set up port forwarding for both of them.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  9. #9
    Infant of C
    Join Date
    May 2010
    Location
    Karachi, Pakistan
    Posts
    118
    Quote Originally Posted by Elysia View Post
    If you mean that the private port (ie, the port of the computer, not the port on the router), then there should be no problem having two computers listening on port 23 and forwarding different public ports to those private ip addresses, even if they use the same port.
    Otherwise remember that you can't use the same public port for both computers because then the router does not know where to forward the packet (without more advanced rules, as grumpy mentions).
    It may also be that it is an internal restriction of your router if you can't use the private port for two computers and set up port forwarding for both of them.
    I see!
    In such case do you suggest tunneling?
    Actually I am doing my Final Year Project at my academy, and the requirement of the project is to stick with these consumer routers. I can not professional router here. So I have to find some other way around to hit the target. Additionally, I do not have any knowledge of tunneling and I would have to learn it for my project. So i need your recommendations....

  10. #10
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,449
    The idea is this:

    A:23 <--> P:X
    B:23 <--> P:Y

    Where A, B are the IP addresses of your computers behind the router, P is the public IP (ie the IP address you get from your ISP on the WAN side of the router), and X, Y are any arbitrary public ports, ie ports on the WAN side that are visible on the internet.
    You don't really need to enter P, it's just there for completeness sake. If your router refuses to do this, then substitute 23 with arbitrary ports and make sure your software listens on those new ports.

    Enter this information into your router. It's called port forwarding, though some routers may use more "consumer friendly" terminology for it.
    Then you can connect to your computers by connecting to P:X and P:Y.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #11
    Infant of C
    Join Date
    May 2010
    Location
    Karachi, Pakistan
    Posts
    118
    Thanks a lot. Cboard is a platform where I have learnt much more than any where else.
    After I am success full in performing this, I might be back to tease you peoples again.
    Thanks again....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. PC as a router
    By C_ntua in forum Tech Board
    Replies: 10
    Last Post: 04-27-2010, 03:08 PM
  2. Router Information
    By NiSA in forum Networking/Device Communication
    Replies: 4
    Last Post: 05-31-2007, 02:50 PM
  3. router
    By kermit in forum Tech Board
    Replies: 9
    Last Post: 07-15-2005, 05:17 PM
  4. Aim/Router
    By RoD in forum Tech Board
    Replies: 2
    Last Post: 03-13-2004, 01:55 AM
  5. DSL & Router
    By Thantos in forum Tech Board
    Replies: 6
    Last Post: 08-14-2003, 01:55 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21