Simple DHCP settings in Linux

Source: Internet
Author: User
Article Title: simple DHCP settings in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Environment: RH linux 9.0 uses common dhcpd packages in linux.

Latest Version dhcp3.0.5: Download

1. install the software: Install the/tmp directory first.

# Cd/tmp

# Gunzip dhcp-3.0.5.tar.gz

# Tar xvf after the dhcp-3.0.5.tar is unlocked, you will see a new sub-directory dhcp-3.0.5 under the Directory

# Cd dhcp-3.0.5 // enter this subdirectory

# Configure

# Make

# Make install dhcp

2. Configuration

The most important configuration work of the dhcp service is to configure/etc/dhcpd. conf and paste the configuration of the local machine.

/Etc/dhcpd. conf:

Default-lease-time 1296000;

# Maximum IP address expiration time

Max-lease-time 4000000;

Option subnet-mask limit 255.0;

# Subnet Mask

Option broadcast-address 192.168.0.255;

# Broadcast address of the Network

Option routers 192.168.0.254;

# Gateway address

Option domain-name-servers 211.151.48.59, 211.151.48.47;

# Domain name resolution address

Ddns-update-style ad-hoc;

Subnet 192.168.0.0 netmask 255.255.255.0 {

# Define the IP address pool content

Range 192.168.0.100 192.168.0.240;

# The IP address range is 100-240, with a total of 140 IP addresses.

}

# You can also specify an IP address based on the MAC address as follows:

# Host Jephe {hardware ethernet 00: a0: c9: a6: 96: 33; fixed-address 192.168.1.12 ;}

The dhcpd. conf file has been configured.

3. Start the service

# Dhcpd

That is, it can be started in command line mode.

Add the command to the startup.

Edit or create the/etc/rc. d/init. d/dhcpd file and write the following content:

     
      #vi /etc/init.d/dhcpd. /etc/rc.d/init.d/functions. /etc/sysconfig/network# Check that networking is up.[ ${NETWORKING} = "no" ] && exit 0[ -f /usr/sbin/dhcpd ] || exit 0[ -f /etc/dhcpd.conf ] || exit 0RETVAL=0# See how we were called.case "$1" instart)# Start daemons.echo -n "Starting dhcpd: "daemon /usr/sbin/dhcpd eth1RETVAL=$?echo[ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd;;stop)# Stop daemons.echo -n "Shutting down dhcpd: "killproc dhcpdRETVAL=$?echo[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dhcpd;;restart|reload)$0 stop$0 startRETVAL=$?;;status)status dhcpdRETVAL=$?;;*)echo "Usage: dhcpd {start|stop|restart|status}"exit 1esacexit $RETVAL
     


The daemon/usr/sbin/dhcpd eth0 clause specifies that the machine in the IP segment of the NIC needs to be parsed.

If the second Nic is set to: eth1

Start and Stop using service commands

# Service dhcpd start | stop | restart

If no error is returned, the configuration file is correct.

Add to the startup service:

# Chkconfig -- add dhcpd

# Chkconfig -- level 2345 dhcpd on

# Chkconfig -- list dhcpd

# Dhcpd 0: Disable 1: Disable 2: Enable 3: Enable 4: Enable 5: Enable 6: Disable

The configuration is complete!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.