DHCP?

Discussion in 'Programmer's Corner' started by rougie, Aug 11, 2012.

  1. rougie

    Thread Starter Active Member

    Dec 11, 2006
    410
    2
    Hello,

    Its been two weeks I am reading up alot on Ethernet and networking. Although I pretty much understand what DHCP is... there still is a grey zone which I don't quite understand?

    I have a computer which is connected to a router as part of a LAN. My computer is DHCP enabled and is set up as: "Obtain an IP address automatically". Meaning that it will obtain its IP address from the router.

    That being said, when my computer wants to go on the internet, it uses the IP address it was assigned by the router to get access to the Internet. However, I know that my computer's IP address is '192'168'1'102'. I know this because when I ping my computer with c:/ping '192.168.1.60' I obtain a successful feedback.

    So my question is what is the difference between the dynamic IP address assigned to my computer by DHCP and my computer's IP address of '192.168.1.102?

    Is it:

    A) they are actually the same
    b) they are two different addresses where one is for the access to the Internet and the other is applicable only within the LAN

    Confused!

    Thanks for all help!
    r
     
  2. nerdegutta

    Moderator

    Dec 15, 2009
    2,515
    785
    Is your computer the only one on the LAN or could the xxx.xxx.xxx.160 be another computer? As far as I know, one NIC, one IP.
     
  3. panic mode

    Senior Member

    Oct 10, 2011
    1,319
    304
    DHCP is scheme invented to make admin job easier - computer can be connected to network and it will be handed down address along with other settings (mask, dns).

    static address must be assigned manually.


    once you got the address (static or DHCP) everything else is equal.

    often routers are configured to only give addresses in certain range, while rest is assigned manually so yes, one can mix and match. also if you are on a network with DCP server, nothing prevents you from manually setting IP to some computer. as long as settings are valid, you are ok.

    static IP has some advantages - it is static (does not change) which makes it suitable for servers or any shared resources (router or printer for example). also NIC with statically assigned IP can be assigned more than one IP address. i use that often - specially at work when i need to connect to more than one network at the same time.

    ping is used to check if particular ip address is accessible (physical network connections exist from one node to another). it is not suited to check own ip address. for that you would need to use 'ipconfig' (if your machine is running windows) or 'ifconfig' or 'ip addr show' (if unix machine) for example.
     
    Last edited: Aug 11, 2012
  4. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,802
    832
    Generally speaking, one NIC: one IP.
    But you can have many IP:eek:ne NIC with static addresses
     
    Last edited: Aug 11, 2012
  5. nerdegutta

    Moderator

    Dec 15, 2009
    2,515
    785
    Yes, I know. I got on box running Citrix Xen, with 3 virtual linuxdistros. I all comes down to software.
     
  6. rougie

    Thread Starter Active Member

    Dec 11, 2006
    410
    2
    I thank all for your replies ... it is very kind of you all.

    huuummm..... still confused!

    Okay, let me try it a different way... "Question by question" Let's go back one step cause I really want to know what is going on so please bear with me here!!!

    If I go out to Best buy and buy a new computer and bring it home, and then I take it out of the box and plug it into the 120VAC outlet and press the on button of the computer I will boot up to Windows.

    At this point please note that the computer is bran spanking new and it is not connected to any router, LAN or modem. Next, if I get into a DOS session and type:

    c:/ipconfig /all

    At this very moment, will there be an IP address shown for this machine?

    thank you in advance for your collaboration!
    r
     
  7. nerdegutta

    Moderator

    Dec 15, 2009
    2,515
    785
    That is the default IP address the OS assigns the network card, when there is no connection to a DHCP, and there is no static IP assignment in the OS software.
     
  8. rougie

    Thread Starter Active Member

    Dec 11, 2006
    410
    2
    okay, when you say "default IP address" is it a preset value like:

    '192.168.1.101'
    or
    '192.168.1.1'

    or is it a random IP value chosen by the computer that no one could guess?
     
  9. nerdegutta

    Moderator

    Dec 15, 2009
    2,515
    785
    None of the above. Those are Class C IP addresses. Let me boot a Microsoft box and see.

    EDIT:Um... It says Media disconnected, and when I connect the network cable, it get an IP from my DHCP. What is the IP address you get ion the PC?
     
    Last edited: Aug 11, 2012
  10. rougie

    Thread Starter Active Member

    Dec 11, 2006
    410
    2
    oh! I see what's going on. Correct me if I am wrong....

    When a PC is not connected to anything and we do ipconfig /all, there is still a physical MAC address but no IP addresses assigned. When we plug in the computer to a router that's part of a LAN AND if the computer is DHCP enabled, we get an IP address such as the one I have : '192.168.1.103'.

    On the other hand when we plug in the computer to a router that's part of a LAN AND if the computer is DHCP disabled, we are allowed to assign the computer our own IP address hence a static IP address for ex: '192.168.1.111' and making sure of course that no other computer is using '192.168.1.111'.

    So right now, my computer has '192.168.1.103'. Suppose I want to change this address and obtain a new one fron the router, can I use 'renew' to do that ?? I don't dare to try it right now... unless you say that it is okay!

    Thanks for your help!

    r
     
  11. panic mode

    Senior Member

    Oct 10, 2011
    1,319
    304
    you can use ipconfig with renew parameter and DHCP will assing the ip address again (it may be the same one unless some other node was given that address).

    or

    you can set your pc to static address (even tough router is still DHCP) and give it some free address such as 192.168.1.200 for example. if it is on same subnet and subnetmask and DNS are correct, you are in business... it does not matter who assigned the address, as long as it is correct. you will still be able to connect to other computers and access their shared folders or access internet.

    normally home networks are all class C so all settings are same on all machines except last octet of the IP address.
     
    Last edited: Aug 11, 2012
  12. rougie

    Thread Starter Active Member

    Dec 11, 2006
    410
    2
    Hello panic mode,

    Okay so my computer had the IP address of 192.168.1.103. I then assigned a static IP address to it as being '192.168.1.122'. I then started a DOS session and tried to ping '192.168.1.103' and it failed. So I then tried to ping '192.168.1.122' and it worked. So everything is fine.

    Then I re-assigned my computer to obtain its address automatically from DHCP. So this time when I went back to a dos session and did c:/ipconfig /all, I got '192.168.1.101' as my newly assigned Ip address. But here's the rub.

    What if I wanted my newly assigned IP address to be back to '192.168.1.103' instead of '192.168.1.101' ??

    Thanks for your help!

    r
     
  13. panic mode

    Senior Member

    Oct 10, 2011
    1,319
    304
    you have two options:
    1. assign static IP address
    2. configure router so it reserves addresses for specific MAC addresses (then even though you use DHCP, your machine will always get same IP - when connected to THAT network).
     
  14. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    You need to configure your dhcp server to do that. If it is some dumb box like an adsl router then it probably won´t be possible. Unless you lease all the remaining IPs and then let the router assign the free .101 address to you, but it is not worth the time spent anyway.
    If you need some specific ip, you set it statically and not hope that the router assigns it to you.
     
  15. rougie

    Thread Starter Active Member

    Dec 11, 2006
    410
    2
    Hello Kubeek and panic mode,

    okay, the assign the the IP as static I get! But I have never configured my router to reserve an IP. I know about port forwarding, Port trigerring, but never used my router to reserve an IP ??

    Do you guys know of any link that can explain how to do this or list a few simple steps on how to do this.

    Thanks for your help
    r
     
  16. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    You need to go find what type of router you have.
     
  17. rougie

    Thread Starter Active Member

    Dec 11, 2006
    410
    2
    my router is a linksys!

    i don't have the model# at hand right now... but i think they are all similar !
     
  18. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    Well you should be able to find a manual for it, but i doubt that it would be able to do this. The only thing I came across that was capable of such things, apart from cisco, was mikrotik routers. These are not very cheap, but they can do almost anything you can dream of.
     
  19. panic mode

    Senior Member

    Oct 10, 2011
    1,319
    304
    not all routers may support it. i am connected to TP Link right now and I see that this feature exists under DHCP→Address Reservation...
     
  20. panic mode

    Senior Member

    Oct 10, 2011
    1,319
    304
    Last edited: Aug 15, 2012
Loading...