.
Showing posts with label Configuring Your Laptop to Use DHCP. Show all posts
Showing posts with label Configuring Your Laptop to Use DHCP. Show all posts

linux dhcp configuration

 
(DHCP) Dynamic Host Configuration Protocol  automatically assigns IP addresses and other network configuration information (subnetmask, broadcast address, etc) to computers on a network. A client configured for DHCP will send out a broadcast request to the DHCP server requesting an address. The DHCP server will then issue a "lease" and assign it to that client. The time period of a valid lease can be specified on the server. DHCP reduces the amount of time required to configure clients and allows one to move a computer to various networks and be configured with the appropriate IP address, gateway and subnet mask. For ISP's it conserves the limited number of IP addresses it may use. DHCP servers may assign a "static" IP address to specified hardware. Microsoft NetBios information is often included in the network information sent by the DHCP server. 
 
DHCP assignment:

  1. Lease Request: Client broadcasts request to DHCP server with a source address of 0.0.0.0 and a destination address of 255.255.255.255. The request includes the MAC address which is used to direct the reply. 
  2.  
  3. IP lease offer: DHCP server replies with an IP address, subnet mask, network gateway, name of the domain, name servers, duration of the lease and the IP address of the DHCP server.
  4. Lease Selection: Client recieves offer and broadcasts to al DHCP servers that will accept given offer so that other DHCP server need not make an offer.
  5. The DHCP server then sends an ack to the client. The client is configured to use TCP/IP.
  6. Lease Renewal: When half of the lease time has expired, the client will issue a new request to the DHCP server.

DHCP server installation:
  • Red Hat/CentOS/Fedora: rpm -ivh dhcp-x.xxx.elx.i386.rpm
  • Ubuntu/Debian 8: apt-get install dhcp3-server
    ( Later releases of Ubuntu (11.04) used the busybox release known as udhcpd and the configuration is NOT shown here)

Starting DHCP server:
  • Red Hat/CentOS/Fedora: service dhcpd start
    (or /etc/rc.d/init.d/dhcpd start for Red Hat, Fedora and CentOS Linux distributions)
  • Ubuntu/Debian: /etc/init.d/networking restart

Sample DHCP server config file: (DHCP v3.0.1)
  • Red Hat/CentOS/Fedora: /etc/dhcpd.conf
    (See /usr/share/doc/dhcp-3.X/dhcp.conf.sample)
    [Potential Pitfall]: Its /etc/dhcpd.conf NOT /etc/dhcp.conf !!
  • Ubuntu/Debian: /etc/default/dhcp3-server
01ddns-update-style interim;                                   # Required for dhcp 3.0+ / Red Hat 8.0+
02ignore client-updates;
03 
04subnet 192.168.1.0 netmask 255.255.255.0 {
05 
06        range 192.168.1.128 192.168.1.254;                   # Range of IP addresses to be issued to DHCP clients
07           option subnet-mask              255.255.255.0;    # Default subnet mask to be used by DHCP clients
08           option broadcast-address        192.168.1.255;    # Default broadcastaddress to be used by DHCP clients
09           option routers                  192.168.1.1;      # Default gateway to be used by DHCP clients
10           option domain-name              "your-domain.org";
11           option domain-name-servers      40.175.42.254, 40.175.42.253;           # Default DNS to be used by DHCP clients
12           option netbios-name-servers     192.168.1.100;    # Specify a WINS server for MS/Windows clients.
13                                                             # (Optional. Specify if used on your network)
14 
15#         DHCP requests are not forwarded. Applies when there is more than one ethernet device and forwarding is configured.
16#       option ipforwarding off;
17 
18        default-lease-time 21600;                            # Amount of time in seconds that a client may keep the IP address
19        max-lease-time 43200;
20 
21        option time-offset              -18000;              # Eastern Standard Time
22#       option ntp-servers              192.168.1.1;         # Default NTP server to be used by DHCP clients
23#       option netbios-name-servers     192.168.1.1;
24# --- Selects point-to-point node (default is hybrid). Don't change this unless you understand Netbios very well
25#       option netbios-node-type 2;
26 
27        # We want the nameserver "ns2" to appear at a fixed address.
28        # Name server with this specified MAC address will recieve this IP.
29 
30        host ns2 {
31                next-server ns2.your-domain.com;
32                hardware ethernet 00:02:c3:d0:e5:83;
33                fixed-address 40.175.42.254;
34        }
35 
36        # Laser printer obtains IP address via DHCP. This assures that the
37        # printer with this MAC address will get this IP address every time.
38 
39        host laser-printer-lex1 {
40                hardware ethernet 08:00:2b:4c:a3:82;
41                fixed-address 192.168.1.120;
42        }
43}
Test configuration file for errors with the following command: /etc/rc.d/init.d/dhcpd configtest
(Other distributions may use: /usr/sbin/dhcpd -f)
Note: The MAC addresses for the static address name server (ns2.your-domain.com),
can be obtained with the command /sbin/ifconfig:
eth0      Link encap:Ethernet  HWaddr 00:02:C3:D0:E5:83
          inet addr:40.175.42.254  Bcast:40.175.42.255  Mask:255.255.255.0
          inet6 addr: fe80::202:b3ff:fef0:e484/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4070 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3878 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3406445 (3.2 MiB)  TX bytes:439612 (429.3 KiB)
                    
When dhcpd is running it will generate entries in the file: /var/lib/dhcp/dhcpd.leases
lease 192.168.1.128 {
 starts 2 2004/12/01 20:07:05;
 ends 3 2004/12/02 08:07:05;
 hardware ethernet 00:00:e8:4a:2c:5c;
 uid 01:00:00:e8:4c:5d:31;
 client-hostname "Node1";
}

Options:
  • ddns-update-style:
    • interim: allows your DHCP server to update a DNS server whenever it hands out a lease. Allows your DNS server to know which IP addresses are associated with which computers in your network. Requires that your DNS server support DDNS (Dynamic DNS).
    • none: to disable dynamic DNS updates or DNS is not supporting DDNS.
    • ad-hoc: been deprecated and shouldn't be used
  • Default options (Red Hat/CentOS/Fedora) are set in /etc/sysconfig/dhcpd
LANs separated by routers: In order to have your DHCP broadcast pass through a router on the the next network, one must configure the router to allow DHCP relay. (Cisco: ip-helper address, Juniper: dhcp-relay) The local lan subnet{ } configuration must come before the configuration directives of the remote LANs.
Look for errors in /var/log/messages
See dhcp-options man page below.


DHCP man pages:

DHCP RFC's: RFC2131, RFC1541 (obsolete), RFC2132
Note: DHCP client will overwrite your /etc/resolv.conf file with new information recieved from the DHCP server.

Red more :
Configuring Your Laptop to Use DHCP

Configuring Your Laptop to Use DHCP

 

1. Registering for DHCP

Configuring Your Laptop to Use DHCP

 

    Network (IP) addresses are assigned to laptop computers using the Dynamic Host Configuration Protocol (DHCP). DHCP automatically configures all required network settings. To use DHCP at LCO, you must first register the MAC addresses of your machine. This applies to all visitors at LCO, not just at Magellan. We request that you register your machine at least four days in advance of your visit, to be sure that you will be ready to plug into the network when you arrive at LCO. You need to register only once for each MAC address regardless of the number of subsequent visits to LCO. DHCP works at the El Pino office as well as on the mountain top.
    To register just go to:
    http://www.ctio.noao.edu/noao/node/add/network-connection
    You will be asked to submit the following information:
    1. Your full name.
    2. Your permanent email address.
    3. The hardware address of all your laptop's network interfaces (e.g - both wireless and ethernet).

    After submitting the form, you will receive a return email to confirm registration.

    Other network information can be found at: http://dns1.lco.cl/pub/slash/etc/hosts
    Do not self-assign IP numbers.
The hardware (MAC) address of your ethernet or wireless card is a 48-bit number that will appear as six pairs of hexidecimal digits (e.g. 0-9 or A-F) and is usually separated by colons (:) or sometimes dashes (-) on computers running Microsoft operating systems. A typical example might look like 00:90:27:D0:AF:D5. A number like 192.168.0.4, which has four sets of number separated by periods, is of course the IP number which is a different beast entirely.
Sometimes the number may be written on the card, or in the case of an internal interface, on the back of the laptop itself.
Linux:
    Run "/sbin/ifconfig -a". The ethernet address is the number by HWaddr in the eth0 information. The number may also be found in /etc/sysconfig/hwconf.
Windows 95/98/ME:
    Run the command winipcfg. The ethernet address is listed in the window that appears as "adapter address".
    Make sure that you have selected your ethernet card in the drop down list (there may be PPP entries for example).
Windows NT:
  1. Right click "Network Neighborhood" and select "Properties"
  2. Click the "Adapters" tab
  3. Click "Properties". The number appears (without colons) next to "Ethernet address".
Windows 2000:
  1. Run "winmsd"
  2. Open "components", "network", then "adapter"
  3. Locate your network adapter in the list that is displayed. The number appears next to "MAC Address"
Windows XP:
  1. From the start menu select: Control Panel -> Network and Internet Connections -> Network Connections -> Local Area Connection
  2. Click the "support" tab
  3. Click "details" The number appears next to "Physical address".
MacOS 8.0-9.2:
  1. Open the TCP/IP control (Apple Menu -> Control Panels -> TCP/IP)
  2. Click on the "info" button and read the "hardware address". If no "info" button appears in the TCP/IP control panel, pull down the Edit Menu -> User Mode and select "advanced"... Now the "info" button should appear.
MacOS X:
  1. Open the Network Preferences (Apple Menu -> Location -> Network Preferences)
  2. On the "Show:" drop menu select Built-in Ethernet. The Ethernet Address: field is your hardware address.

3. Configuring your Laptop to use DHCP


The following procedures will configure your computer to run DHCP. Reboot your computer for the changes to take effect.
Linux:
As root run netconfig (or redhat-config-network or equivalent). On the second screen select "Use dynamic IP configuration (BOOTP/DHCP)" using the space bar and tab to select "OK". No other settings or changes are necessary.
Windows 95/98/ME:
  1. From the start menu select: Settings -> Control Panel
  2. Double-click the "Network" control panel.
  3. Select the "Configuration" tab.
  4. Double-click the "TCP/IP" component for your ethernet adapter (not the dial-up adapter or AOL adapter if you have those).
  5. On the "IP Address" tab check the box for "Obtain an IP Address automatically".
  6. Select the "Gateway" tab. If any address appears under "Installed gateways" select it and click "Remove".
Windows NT:
  1. From the start menu select: Settings -> Control Panel
  2. Click the "Network" control panel
  3. Select the "Protocol" tab
  4. Select "TCP/IP" and click "Properties"
  5. Select "Obtain an IP address from a DHCP Service"
Windows 2000:
  1. From the start menu select: Settings -> Network and Dial-up Connections -> Local Area Connection
  2. Click the "Properties"
  3. Select "Internet Protocol (TCP/IP)"
  4. Click "Properties"
  5. Check the boxes for "Obtain an IP Address automatically" and "Obtain DNS server address automatically". The other boxes should gray-out.
Windows XP:
  1. From the start menu select Control Panel -> Network and Internet Connections -> Network Connections -> Local Area Connection
  2. Click the "Properties"
  3. Select "Internet Protocol (TCP/IP)"
  4. Click "Properties"
  5. Check the boxes for "Obtain an IP Address automatically" and "Obtain DNS server address automatically". The other boxes should gray-out.
MacOS:
  1. Open the TCP/IP control (Apple Menu -> Control Panels -> TCP/IP)
  2. Set the "Connect via:" selection to "Ethernet built-in"
  3. Set the "Configure:" selection to "Using DHCP Server". All other fields should be blank.
  4. Close the TCP/IP control panel.
  5. Click "Save".
MacOS X:
  1. From the Apple Menu choose "System Preferences" then "Network"
  2. Select the "TCP/IP" tab.
  3. Set the "Configure:" selection to "Built-in Ethernet".
  4. Set the "Configure:" selection to "Using DHCP".
  5. Add "lco.cl" to the "Search Domains" field.
  6. Close the TCP/IP control panel.
  7. Click "Save".