How to connect to a client in Broadband shared IP - c

I am using a Broadband Router on which multiple pcs use the same shared ip as the public ip. how can some other remote client get a specific IP address to connect to me?
I was developing a Client/Server Chat Program using C.
Thanks for considering.

They cannot. The broadband router is the only one with a public IP address.
The usual solution to this problem is to have the router forward a specific port to one of your NAT'd internal machines.
If that's not sufficient, you could investigate "hole punching" and STUN.

Related

How to differentiate between two or more devices in the same ip address (wifi)?

I am currently working on networking project that share files between mobile devices using p2p technology. Using wifi or mobile network. The main problem is when using wifi the general ip address become the same for all connected devices to that wifi connection and this is the problem how to send the file to a particular one if all connected devices have the same ip address?
Every device on same network has private IP addresses which are unique. All of them shares one public IP address. Now how do server distinguish them by only seeing their public IP and send them data?
Well the answer is the server doesn't see only IP address. It sees IP:Port. Every private IP connected to the server has same public IP but different port. The public IP belongs to your NAT. Your NAT assigns unique port to every private IP addresses and maps them. The mapping is like this [private IP, private port, public IP, public port, transport protocol].
So when your server sends a packet to public IP:port then the packet is forwarded to the mapped private IP:port. And your device with that private IP:Port receives it.
Use the mac address which is uniques for every device you pick.
Comparing mac address will be easy when you encounter multiple devices with same IP address.

Cisco IP forwading challenge on a cisco router

I have been trying to setup a cisco gateway router that has a Mail server behind it. The challenge has been that the static nat entries are no effective or perhaps do not work. Has anyone done this in areal life environment? testing for open ports shows that all the static NAT ports are closed .Please share
Try this:
ip nat inside source static tcp LAN_MAIL_IP_ADDRESS 25 MAIL_PUBLIC_IP_ADDRESS 25 extendable
!
interface FastEthernet0/1
description "TO INTERNET"
ip nat outside
!
interface FastEthernet0/0
description "TO LAN"
ip nat inside
I Actually found out that the problem was the gateway on the mail server that was still pointing to the old ISP instead of the router connecting to the new ISP.

Nat vodafone mobile italia

I'm trying to display some cameras connected to a dvr which in turn is connected to a Huawei router that has the ability to connect to the Internet via the mobile network.
I tried with a tim card and everything goes wonderfully (the tim's ip is dynamic so I have used no-ip to be able to always access the dvr and I made the forwarding by opening the right doors outside to the inside), but as the area in which you installed the dVR, it does not take tim signal (not even wind, or 3), I had to put the vodafone's sim but from what I've read on the internet but not the public ip to mobile customers, but access through NAT ..
None of you know the way to be able to access a remote PC via a network that uses NAT?
When behind NAT, the best course of action is to establish a connection from inside the NAT to some remote machine.
There are several ways to achieve that, such as creating a (reverse) ssh tunnel or using a remote desktop utility such as logmein, teamviewer or ammyy.

Broadcast on different subnets

Please if you can help me about my problem. On one side I have server with IP 172.27.13.2 connected to the WAN interface of router 172.27.13.1 ...Then on wireless LAN of my router 192.168.1.1 I have connected a few clients. Now I will write code in C where client are requesting some UDP streams from server, then server broadcasts streams to clients, and if some packets get lost clients must send NACK to server. My questions is:
Because server and clients are on different subnets how can I broadcast from server?
And how the client can send request and NACKs to server because they are in different subnets?
Are these problems can be solved by router configurations or in C code?
Thank you for helping
You cannot broadcast to different subnets. Routers do not usually forward broadcast packets to different subnets, unless you have a very special router that can be configured properly (e.g. Cisco ...). You could however use multicast for such a task. Here's a C example
Also check this: UDP broadcast packets across subnets
NOTE: some includes in the c example are missing, but they are easy to find
As both server & users are in different subnets .As router donot forward broadcast .But we have solution by modifying the router configuration .
If you have cisco router & users are connected on cisco switch ,you can use ip helper address command on switch on vlan .You can allow udp packet on router ACL

How to connect socket via external IP (Mac )

My question is, how to connect to socket on romote mechine?
I can only connect sockets on same network..
I wrote a simple code (in c), that simulate a server (open socket and listen for client). in Mac.
I'm trying to connect this socket as a client from iPhone (with simple objectiv-c code).
If my internet on both, server and client, is on the same network (WiFi) and in client I trying to connect to 192.168.1.x, it's working.
But when, in client, I'm trying to connect via external IP (with the same port) connection is failed.
I never did this bofore. Maybe I miss somthing.. I've tried to turn my FireWall off. It did not help.
Thanks.
Edit: If it's not clear.. my Mac is connected by router.
In a setting like this, the "external IP" would typically be the IP of the router. In all likelihood you'll need to configure the router to forward the relevant port to the internal IP address.
It could also be the case that for the port forwarding to work, the request has to come in on the external (WAN) interface. This depends on how the router is configured. If that's the case, you'll need to make sure that you're accessing the external IP via the cellular network and not the Wi-Fi connection on your iPhone.
If you're connecting to your server via a local IP address (i.e., you're connecting to another machine on the same local router via a delegated DHCP address), then your issue is on the network, not the IP-stack of the local machine.
You'll need to look into your router settings ... many routers will block a number of services, especially those on custom ports, in order to prevent malicious attacks from sources external to the local network.

Resources