How to access private ip address [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I have my laptop that is connected to Internet through my Android mobile which is having its hotspot application running. Now my laptop must have been provided with private ip and my mobile is using a public ip address. I am running a web server on this laptop. Now how can I access this web server from my friends laptop which is not a part of the network ?
I mean which ip address should I provide private ip of the laptop or the public ip address of my mobile?

First your need to find out the following two information:
Your laptop's private IP on which your web server listens on. Use ipconfig on windows or ifconfig on linux or mac.
Your public IP (If you don't know how to find this, you could navigate to www.whatismyip.com and it will show you your public IP)
Then setup a port forwarding rule in your router that forwards a port to your laptop's web server's port. It's not a good idea to forward any port to your laptop, so pick one port. This can be the same port as the port your webserver is configured to listed on.
Lets say you have your web server running on 8080 on your laptop, you would setup a port forwarding rule that maps source port 8080 to your laptop's private ip on port 8080.
You then use the public ip along with the port from outside your internal network. E.g. http://xx.xx.xx.xx:8080

If you want to Access the Website outside the Network, you have to use the public ip.
With the private ip you just can Access ist within Your Network.
I recommend you to get a webserver, because your public ip changes with every reconnect, but at least onces in 24h. And most phone providers do not allow server hosting.

Related

How to permanently mount a windows share folder in Lubuntu use PC NAME? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I am using a java program on Lubuntu which backs up my windows computer through Wi-Fi LAN. I need to access to his windows shared folder but with PC-NAME, not with IP Address. How can I do that?
I am using cifs utils to achieve that and for permanent mount it is in /etc/fstab:
//PCName/ShareF /media/PCName/ShareF cifs credentials=/home/user/.myrcre
But I get this error:
mount error: could not resolve address for PCName: Unknown error
I need to access the windows PC through its name, not ip address, because I dont want to set the static ip, and because of that, the IP address changes sometimes. I need it mounted permanently, no matter if server or client is shuted down.
Maybe, it is here some another possibility, e.g. java code could obtain IP address from PCName, but I dont know why. Cant find anything.
Thank you for any answer.
First of all, Lubuntu needs to know who is PCName, so ping it from terminal and verify:
ping PCName
If you can resolve PCName to XXX.YYY.KKK.ZZZ, you can mount it.
If you can't resolve the name, Lubuntu can't mount an undefined network resource and i suppose that it's your case:
mount error: could not resolve address for PCName
This is a network question, not really a programming question.
Have you a Domain Server or a DNS server in the network?
If you have it, on your Lubuntu PC set the DNS server to that ip and try to resolve PCName again. Lubuntu will be able to resolve PCName asking to the server (DNS or DC).
Have you access to the DHCP server (on the router I suppose) ?
If you have it, you can map you PCName's MAC address to a particular fixed address. Your Windows PC is still in DHCP but it receive always the same ip.
On Lubuntu add a row in /etc/hosts and the trick is done.
Can't you apply those solutions? ARP-scanning
If you know your Windows PCName's mac address, you can make an ARP scan on the network.
You'll receive a map IP -> MAC so from MAC you get the IP. Now, you can mount your PCName by his IP.
This solution may fail if a firewall, an antivirus software or a IPS block the arp-scanning.
Remember : you can do all linux commands throw Runtime.exec, read this other question. If you can do it in Linux, you can do it in Java

Access Tomcat server Outside network

I have tomcat 8 server and I want my friend who is in another country to look my web application. I saw many answers regarding such question and followed everything (changing connector port address, router forwarding and firewall too). I am using Zyxel router and did forwarding and added my public ip address in Hosts file as well.
Can you please suggest me what step I am missing or doing anything wrong? Please note: while adding application in router (Port forwarding) I used server I address as my IP Address and Service Name as HTTP and Port 80.

Can I access my application running on localhost:8080 from WAN..?

I developed an application in my home machine. Now I want to show application that i made to client through WAN. I have TP-Link WiFi router at my home. Is it possible using port forwarding or other solution ?
Yes, you can use port forwarding to make your application accessible from the Internet. Essentially, what you want to do is redirect traffic coming into your public IP on port 80 to the internal machine running tomcat on port 8080.
There are public guides available for configuring port forwarding on different routers.
Edit: Port forwarding however might not be the only problem. There are other things to consider:
1. You should use a static external IP and map it to a DNS name, so users will be able to access the site by typing the name in the address bar.
2. You should make sure that the machine running tomcat allows external connections to port 8080, so these aren't blocked by the firewall.

Java Linux ServerSocket does not do much [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am running Linux Fedora 18 and all I want is my java code to print hello linux in a web browser I type in http:// myhostname. I have use my code in windows and it work find. However in Linux I use port 80 got a permission denied. So I then I use port 8080 no permission denied but it didn't work. Using port 80 the client dose accept and I can send and receive information only on machine the seversocket not on a different even if it is connect ton the network.Last thing I have made policy file to allow port 80 to work but it was useless and I still not sure I to set a policy file in my code. Sorry if this long question but I have been researching this issue for a month not so please don't tell me to google it. So I guess my main question why can't the serverSocket broadcast anything out of the linux machine and how to fix it?
Thank you
On Linux, you need to be root to use system ports from 0 to 1023. Tomcat has ways of opening port 80 without leaving the process running as root, but they are a bit complicated to discuss here. Linux provides ways to give permissions to access these port, but usually I just use port 8080.
If you use port 8080, you need to redirect this using your router to port 80, or you will have to specify that you want to connect to port 8080. Your browser only assumes port 80. e.g. http://yourhost:8080/
To connect to this server from another machine, your firewalls have to be setup so you connect to it all. A firewall is designed to stop traffic you haven't explicitly allowed. This means you may need to open your firewall on your server, and you network router and put the your public IP address (not your internal one) in the hosts file of your client.
I did a yum update and the code work just fine now.

Socket connection request refused [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am trying to have a Socket connection between my laptop and my Android.
I am making laptop as a server. To establish the connection, I am using the IP of laptop as shown by ipconfig (running Windows 7) (this address is not the same as shown by websites like 'whatismyip').
Things work fine when I connect both my laptop and Android to the same wireless router and I use the address given by ipconfig.
However, when I use the EDGE connection of my Android and access the same IP address, the Socket connection request is refused. Also, the IP given by whatismyip doesn't work either with WLAN or EDGE.
I have heard that there are two IP addresses, internal and external. And I suppose that the address given by ipconfig is the internal address. Also, there is some procedure called as port forwarding.
Can someone please help me to access the ServerSocket via the EDGE connection? Which IP should I use for that, and if I need to do port forwarding, how can it be done?
Thanks.
On your laptop, when you run the ipconfig command, the ip address it shows on whatever interface you are connecting to your router with is a private address (not a routable address). The IP address shown by whatismyip is the IP address assigned to your modem. When your phone is connected to your router over Wi-Fi, you are within the same subnet as your laptop, and are able to create a connection. When you are on the EDGE network, you are on a different subnet, and since your laptop's IP is not routable, you can't connect to it. On most routers, you can configure all ingress traffic for a destination port to be sent to your laptop. The configuration for this varies for each router, but the idea is the same. The IP address you want to forward this traffic to is the private IP address of your laptop (the one shown by ipconfig), and the port is whichever port the traffic you are sending is destined for.

Categories