Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Well this might be a simple networking question but a question that is puzzling me. I hope some one can clarify something for me. I have to physical computers, a linux laptop, and gaming computer (really up to date) that I dual boot win7 and ubuntu server. I then set up my apache, ssl, php, mysql on my server. I then changed /etc/hosts/ for my internal IP of my server to just be called for example : myserver.com

Now.. I want to get my external IP in /etc/hosts so that I can connect with my laptop to my server (which will be on)

However I don't know if this is normal but I ran the command :

curl ifconfig.me 

and I was given my external ip on my server which is xx.xxx.xxx.21 i was happy and I used that to connect with my browser and it all works (this made me happy) now I tried the same command on my laptop and I was given the same IP:

xx.xxx.xxx.21

how can two different computers (that I have tested network connectivity) both have the same IP?

And then my second question : why is it when I type in xx.xxx.xxx.21 on my browser and it takes me to my server apache rather then my laptop apache?

On my router port forwarding I have enabled HTTPS for my servers internal IP and I have enabled 80 on my laptops internal IP.

Would love if some one can clarify this for me.

share|improve this question

migrated from serverfault.com Jan 6 '13 at 14:56

This question came from our site for professional system and network administrators.

add comment

1 Answer

What you are seeing is quite normal, and boils down to a technique called Network Address Translation or NAT. Basically, outgoing packets are rewritten by your router to have your ISP-assigned public IP address as the sender, and the router keeps a state table listing the rewrites it has done so that each response packet can be rewritten properly and then routed back to the correct computer.

If you check the IP address on each computer's network interface using e.g. the ifconfig command, you will see that they do indeed have different IP addresses on the "inside".

The above captures the basic elements of NAT; if you want more details, you may want to head on over to Wikipedia: Network Address Translation.

Normally, you would use the internal rather than the external IP address in /etc/hosts on hosts on the "inside" (local) network. That way, you don't have to worry about your ISP assigning you a new address.

share|improve this answer
    
Ah! Alright, I as guessing that since my table in my router indeed has my internals, 150 = for my win7 part (static) 6 = for my server, 3 = for my laptop. And for the /etc/hosts/ I need to have the external on so I can work on my server from school and test my web application. The internal won't be able to work. I have it as : xx.xxx.xxx.21:443 as on my internal ip 192.168.1.6 port 443 is the only open port inside the router. and on my laptop its a personal testing computer so I don't have 443 open. no need. Am I getting this right? –  RaGe10940 Jan 6 '13 at 13:39
    
The format of /etc/hosts is simply <ip-addr> <hostname1> [hostname2 ... hostnameN] with a minimum of one host name assigned. (I'm not aware of any maximum limit, but there might be.) So it sounds like you have it mostly correct, at least. –  Michael Kjörling Jan 6 '13 at 13:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.