7, two configurations for two different subnets configure a DHCP server

Source: Internet
Author: User

The environment is as follows: (for reference, ensure that two subnets can ping each other)

Virtual Machine 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 in Gateway Gate

(eth0) Providing IP address assignment services for 192.168.155.0/24 subnets

(eth1) Providing IP address assignment services for 192.168.170.0/24 subnets

1, Putty connection 192.168.170.4


[Email protected] root]# vi/etc/dhcpd.conf

ddns-update-Style Interim;ignore Client-updates;subnet192.168.155.0 netmask 255.255.255.0{option Routers192.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 range192.168.155.10 192.168.155.198; default-lease-time 86400; Max-lease-time 172800; host www {next-server marvin.redhat.com; Hardware Ethernet12:34:56:78: AB:CD; Fixed-address 207.175.42.254; }}subnet192.168.170.0 netmask 255.255.255.0{option Routers192.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 range192.168.170.6 192.168.170.230; default-lease-time 86400; Max-lease-time 172800; host nd {next-server marvin.redhat.com; Hardware Ethernet12:34:56:78: AB:CD; Fixed-address 207.175.42.254; }}

Set the IP address of the eth0 network card , edit directly

[Email protected] 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 network card, edit directly

[Email protected] 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 NETWORK,DHCP Service

[Email protected] sysconfig]# service Network Restart

[Email protected] sysconfig]# service dhcpd Restart

Test whether two subnets are working correctly

If the Windows-side
① will VMnet1 and VMnet8 (Properties-"tcp/ipv4-" in the "Automatic acquisition of IP" tick, set the DNS server )


Wait a few minutes, normal as (appear network a few )

②cmd into command line Ipconfig/all

(See IP is not within the IP range just set, and the following red part is consistent with the setting)


( Note:

1, because there will be the impact of the lease , If a step set error, restart the DHCP service, the IP address is unchanged, you can adjust the system time for a few days, so that the lease expires, re-access.

2.

See VMnet1 and VMnet8 's IP in the scope of the file you just set? If not, it may be the IP assigned by another virtual machine. It would be nice to shut down the DHCP service.
To the main interface "edit"-"Use the local DHCP service to assign the IP address to the virtual machine" is removed.

Then disable and then start The two NICs to regain

3, may subnet other DHCP server assigned, this time only to see that it is the one that shuts down its DHCP service

If the DHCP service can also be tested with the dhclient command on the Linux side

Second type: Configure DHCP relay proxy server

(If you do the first, close the gate's DHCP service to avoid affecting this experiment)

The DHCP Request broadcast packet is not able to pass through the router because the router is capable of isolating broadcast storms .

Therefore, in VM1 to establish a DHCP server, 192.168.155.0/24 subnet is not available, this time you need to establish a DHCP relay proxy server in VM2.

(two subnets to ping Pass, here VM1 and Vm2ping Pass)

1, in VM1 (170.3) to establish a DHCP server, the basic steps to follow the same basic, that is, /etc/dhcpd.conf file more subnets

[Email protected] root]# vi/etc/dhcpd.conf

ddns-update-Style Interim;ignore Client-updates;subnet192.168.170.0 netmask 255.255.255.0{option Routers192.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 Ethernet12:34:56:78: AB:CD; Fixed-address 207.175.42.254; }}subnet192.168.155.0 netmask 255.255.255.0{option Routers192.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 range192.168.155.81 192.168.155.200; default-lease-time 86400; Max-lease-time 172800;}

2.Gate End

guaranteed Turn on forwarding (previously done can be skipped)

[Email protected] root]# vi/etc/sysctl.conf

Net.ipv4.ip_forward = 1

[[email protected] root]# sysctl-p (change takes effect)

Turn off the firewall , or when you learn the firewall later, directly release 66 and 67 ports

[[email protected] root]# service iptables stop

3,VM2 (155.3) start configuring DHCP relay Proxy Server

First install the DHCP software, refer to the previous article

[[email protected] root]# vi/etc/sysconfig/dhcrelay (set up DHCP server)

# Command Line options hereinterfaces= "eth0"dhcpservers= "192.168.170.3"

[[email protected] root]# service dhcrelay Start (Start relay Service)
Start dhcrelay: [OK]

4, go to the Windows side test

Disable, restart, appear

cmd command line input Ipconfig/all

IP is within set range, correct.

Go to machine 170.3. View assigned IP network information
[Email protected] root]# cat/var/lib/dhcp/dhcpd.leases

7, two configurations for two different subnets configure a DHCP server

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.