Mobile IP Addresses - mobile

I know that when you hit a page on a site your IP gets logged and the owner can view it.
I've seen it with computers.
There can't possibly be enough IPs to cover all computers and cellphones...
So, since mobiles access by 2G, 3G, 4G, what is the IP that gets registered? Is it like PC accessing?
Do they even generate an IP?
I guess that for Wi-Fi connection they do get an IP, so what about the other signals?

With a 3g service provider you are on their network, so the IP Address will go through a NAT firewall/router and the ip of your device will be their public address such as AT&T.
Much like your home router works. Any computer on your home network will share the IP address of the router.

Related

what does "On Your Network" in React mean

What does "On Your Network" mean when I run npm start in a React Project
see image
what does On Your Network: http://192.168.56.1:3000 mean
"On your network" in this context means from another computer that's connected to the same network (eg. the same Wifi network). You could browse your locally-hosted React app from your phone, for example. That IP address is your computer's local IP address (which is different from your public IP address).
"on your network" means that on your local network like your wifi you can access your web page in your local network (that can be your phone or any computer or internet enabled device on your wifi) with that ip address. just type http://192.168.56.1:3000 in your browser.

Running localhost react app on mobile phones

I need to connect my react app to my local network by typing in localhost on any device. Im not sure if this is possible. Right now I use my computers IP address and I type the address into my phone browser with port 300 and it works. The only thing is that I am using auth0 and I need a list of callback urls for it to work. Basically anything other than localhost in the url will be blocked. So i need to type in localhost:3000 on my phone and my react app needs to show up.
You can use a service like lvh.me that resolves back to the IP you provide as the subdomains. This will be fairly stable, but you will need to specify the domain to Auth0.
For example, if your IP address is 10.0.0.5 and your app is running on port 3000, from your local network you would visit http://10.0.0.5.lvh.me:3000/ from your phone. This request would resolve to 10.0.0.5:3000.
I am afraid it's not possible. The localhost refers to 127.0.0.1 IP in your computer which is like a globally followed convention for all the devices in the world.
Your router assigns an IP like 167.12.124.12 for each of the devices connected to it and if any other device is connected to the same router, they can communicate with each other by using the IP the router created for the devices.
The router assigned IP won't change unless your device goes offline for some reason. Try adding the IP as an allowed URL in the list of URLs in Auth0.
Make sure both your phone and computer are connected the same wifii. Then, try to figure out how to find your IPv4 Address. The screenshot below shows where to find it on mac, I guess you can find it by typing ipconfig on terminal, too. This IPv4 address is your localhost. I usually run my react app's on port 3000 so when you go to yourIPv4address:3000 on your mobile phone's browser you can see your react app on mobile. Hope it helps. Good luck.

Raw Sockets - Internet Protocol Layers

I have been working with Raw Berkeley Sockets in C, which allow the programmer to access Layer 2 (IP Headers) of the Internet Protocol Suite. I would like to know how the raw sockets handle transport on Layer 1 (Link Layer), specifically with regard to wireless local area networks.
For example, how does the socket know which network interface (eth0 or wlan0) to send the packet to?
If I am behind a wireless router, should I still fill the IP Source Address of my IP Header with my LAN address (192.168.1.1), or with the internet address (74.125.226.68) of my router?
If I do fill the IP Source address with my LAN address (192.168.1.1), does the IP Header get changed when it goes through the router, or does it stay that way, so that the receiving end of the packet attempts to send the response to a local host on its network?
I would appreciate any insights in this area.
For example, how does the socket know which network interface (eth0 or wlan0) to send the packet to?
You can use the socket option SO_BINDTODEVICE to bind your socket to a specific interface. Otherwise, the operating system chooses one.
If I am behind a wireless router, should I still fill the IP Source Address of my IP Header with my LAN address (192.168.1.1), or with the internet address (74.125.226.68) of my router?
You should use your LAN address. The router is responsible to take care of NAT (network address translation) if necessary.
If I do fill the IP Source address with my LAN address (192.168.1.1), does the IP Header get changed when it goes through the router, or does it stay that way, so that the receiving end of the packet attempts to send the response to a local host on its network?
If NAT is enabled at the router, the source address is changed to reflect the router's external address. Otherwise, your packages are likely to be dropped by routers or firewalls, because your source address is invalid in their context.

How to connect to a client in Broadband shared IP

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.

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