7. Configure the DHCP server and dhcp server for two different subnets.

Source: Internet
Author: User

7. Configure the DHCP server and dhcp server for two different subnets.

 

The environment is as follows: (ensure that the two subnets can be pinged to each other before reference)

Vm1 192.168.170.3 VMnet8 (NAT Mode)

Virtual Machine vm2 192.168.155.3 VMnet1 (host mode only)

Virtual Machine gate 192.168.170.4 (eth1) VMnet8 (NAT Mode)

192.168.155.4 (eth0) VMnet1 (host mode only)

First: configure the DHCP server on the gateway gate

(Eth0) provides IP Address Allocation service for the 192.168.155.0/24 Subnet

(Eth1) provides IP Address Allocation service for the 192.168.170.0/24 Subnet

 

1. putty connection 192.168.170.4


[Root @ mail root] # vi/etc/dhcpd. conf

ddns-update-style interim;ignore client-updates;subnet 192.168.155.0 netmask 255.255.255.0 {        option routers                  192.168.155.4;        option subnet-mask              255.255.255.0;        option domain-name-servers      192.168.155.4;        option time-offset              28800;  # Eastern Standard Time        range  192.168.155.10  192.168.155.198;        default-lease-time 86400;        max-lease-time 172800; host www {                next-server marvin.redhat.com;                hardware ethernet 12:34:56:78:AB:CD;                fixed-address 207.175.42.254;            }}subnet 192.168.170.0 netmask 255.255.255.0 {        option routers                  192.168.170.4;        option subnet-mask              255.255.255.0;        option domain-name-servers      192.168.170.4;        option time-offset              28800;  # Eastern Standard Time        range  192.168.170.6  192.168.170.230;        default-lease-time 86400;        max-lease-time 172800; host nd {                next-server marvin.redhat.com;                hardware ethernet 12:34:56:78:AB:CD;                fixed-address 207.175.42.254;            }}

 

 

 

Set the IP address of the eth0 Nic and edit it directly.

[Root @ mail root] # vi/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0ONBOOT=yesBOOTPROTO=staticIPADDR=192.168.155.4
NETMASK=255.255.255.0GATEWAY=192.168.155.4

Set the IP address of the eth1 Nic and edit it directly.

[Root @ mail root] # vi/etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1ONBOOT=yesBOOTPROTO=staticIPADDR=192.168.170.4NETMASK=255.255.255.0GATEWAY=192.168.170.4

 

Restart the network and DHCP service.

[Root @ mail sysconfig] # service network restart

Service dhcpd restart

VMnet1 and VMnet8 (properties-> TCP/IPv4-> check "automatically obtain IP addresses" and set the DNS server)

Network)

Ipconfig/all

(Check whether the ip address is within the ip address range just set. It is consistent with the red part below)


Note:

1. Due to the impact of the lease term, if an error occurs in a step, the IP address remains unchanged after the DHCP service is restarted. You can set the system time to several days to invalidate the lease and obtain it again.

 

2,

Check the range of the VMnet1 and VMnet8 IP addresses in the file just now? If not, it may be the IP address allocated by other virtual machines. Just disable the DHCP service.
Go to the main interface "edit"-"and remove the" use local DHCP service to allocate IP addresses to virtual machines "check box.

Disable and then start the two NICs and obtain them again.

 

3. Other DHCP servers in the subnet may be allocated. At this time, you can only check the IP address used to disable the DHCP service.

)

 

In Linux, you can use the dhclient command to test the DHCP service.

 

Type 2: configure the DHCP relay Proxy Server

(If the first type is used, first disable the gate DHCP service to avoid affecting this experiment)

DHCP request broadcast packets cannot pass through the vro because the vro has the function of isolating broadcast storms.

Therefore, you cannot obtain the IP address 192.168.155.0/24 subnet when setting up a DHCP server in VM1. In this case, you need to create a DHCP relay proxy server in VM2.

(Ping is required for the two subnets. VM1 and VM2ping are enabled here)

 

1. Create a DHCP server in VM1 (170.3). The basic steps are basically the same as in the previous article, that is, the/etc/dhcpd. conf file has multiple subnets.

[Root @ localhost root] # vi/etc/dhcpd. conf

ddns-update-style interim;ignore client-updates;subnet 192.168.170.0 netmask 255.255.255.0 {        option routers                  192.168.170.4;        option subnet-mask              255.255.255.0;        option domain-name              "gr.org";        option domain-name-servers       192.168.170.3;        option time-offset              28800;        range dynamic-bootp  192.168.170.30   192.168.170.110;        default-lease-time 21600;        max-lease-time 43200;        # we want the nameserver to appear at a fixed address        host ns {                next-server marvin.redhat.com;                hardware ethernet 12:34:56:78:AB:CD;                fixed-address 207.175.42.254;            }}subnet 192.168.155.0 netmask 255.255.255.0 {        option routers                  192.168.155.4;        option subnet-mask              255.255.255.0;        option domain-name-servers      192.168.155.3;        option time-offset              28800;  # Eastern Standard Time        range  192.168.155.81   192.168.155.200;        default-lease-time 86400;        max-lease-time 172800;}

2. gate end

Ensure that forwarding is enabled (you can skip it before)

[Root @ localhost root] # vi/etc/sysctl. conf

Net. ipv4.ip _ forward = 1

[Root @ localhost root] # sysctl-p (changes take effect)

Close the firewall, or open ports 66 and 67 directly when you learn the firewall later.

[Root @ localhost root] # service iptables stop

 

3. Configure the DHCP relay proxy server in VM2 (155.3)

Install the DHCP software first. refer to the previous article.

[Root @ localhost root] # vi/etc/sysconfig/dhcrelay (set DHCP server)

# Command line options hereINTERFACES="eth0"DHCPSERVERS="192.168.170.3"

 

[Root @ localhost root] # service dhcrelay start (start Relay service)
Start dhcrelay: [OK]

4. Test on Windows.

Ipconfig/all

Go to 170.3 to view the allocated IP Network Information
[Root @ localhost root] # cat/var/lib/dhcp/dhcpd. leases

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.