Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

IP address

  1. Sep 11, 2011 #1
    what is the difference between router's ip address and my lan ip adress....

    what i understood is that we have a lan ip adress and a wan ip adrress ...now my wan ip address is found using whats my ip address address.com and it changes...hence dynamic...and my lan ip address is using ifconfig...but then everybody seeems to have same lan ip address ....and whats the work of a NAT...?
  2. jcsd
  3. Sep 11, 2011 #2
    Since Internet IP addresses are limited and expensive, your ISP gives your router one IP address so that it can appear on the Internet as a single device. Most ISPs change this address periodically for various reasons, unless you pay them extra for a static (unchanging) IP address--which you might do if you are running a server, for example, so that the name servers on the Internet (the devices that know how a domain name maps to an IP address) know your IP address.

    The router is a single device on the Internet. So one of the router's jobs, then, is to make everything behind it (everything on your LAN) appear as a single device on the Internet. It does this by modifying the packets as they come in and go out. That's NAT.

    So that devices on your LAN can talk among themselves (including the LAN side of the router) each of them can be given a separate IP address and you don't have to pay for those because you're using them locally. You can either program an IP address into every device, or tell a device to ask the router for a free IP address for use on the LAN. The latter is most often used. The process of asking the router for an IP address to use locally is called DHCP. The IP addresses used locally should use those that are reserved for local traffic, like those that start with 192.168.x.x. This is so they are never confused with actual Internet IP addresses, as described in the next paragraph.

    When a LAN device does want to access the Internet, it simply acts as if its on the Internet (sending packets to the Internet device using that destination device's Internet IP address). The router sees those packets and translates them accordingly before sending them out to the internet.

    On a side note, there's not really a standardized way for a local device to find out the WAN (Internet) IP address of its own router in case it wants to tell it to some other device on the Internet so that other device can send unsolicited packets to the first device (also, your router won't allow unsolicited incoming packets unless it see a local device first send a packet to that device. Both devices must send a packet or two to the other to get the router to allow subsequent packets--this is called hole-punching). That's why an Internet peer-to-peer connection always requires a server on the Internet to set it up--because that server can see what the WAN addresses are for the two peers, and tell each the other's address. Then each device can send a hole-punching packet to the other to get their routers to allow more packets. There are even free servers out there just for doing this, called STUN servers. That's so you can, for example, write a game that sets up peer-to-peer connections using a free STUN server.
    Last edited: Sep 11, 2011
  4. Sep 11, 2011 #3


    User Avatar
    Homework Helper

    The price for multiple WAN ip's is being reduced over time. Cable modems support up to 16 WAN IP's, although in the case of Cox cable, it's limited to 3 WAN ip's and each additional ip costs about $7 / month. ATT's DSL static ip block is $15 / month for 8 ip's, but 3 of those are overhead, so you end up with 5 static ip's.

    Note that when you have a multiple ip setup with one ip per computer, you lose the LAN, since each computer is effectively connected to directly to the internet and not directly to each other. In the case of a cable modem, if you remove the ISP (coax) cable from the cable modem, it will then act as a LAN router, and assign local ips (192.168.x.x) to each computer. (Note you could have a mix of computers and routers, each with it's own WAN ip, connected to the ISP modem).

    A router using one ip for multiple computers remaps the "port" addresses in each packet sent by the computers (it undoes the mapping on packets sent back to the computers). This can be an issue if trying to play an online game with multiple computers since the games often want to use specific port addresses. Having a multiple ip setup (one external WAN ip per computer) solves this issue (but then there's no LAN unless you disconnect the cable or dsl modem from the ISP and reboot everything).
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook