How To DHCP on a Private Network with VM's :
====================================
Hypervisor : - Hypervisor-Host
DHCP Client : - Host-DHCP-Client
DHCP Server : Host-DHCP-Server
DHCP server:(Imp files/command)
Config file : /etc/dhcpd.conf
Pid file : : /var/run/dhcpd.pid
The DHCP daemon can be configured with command line options by using the /etc/sysconfig/dhcpd file.
For security, DHCP can be bound to an interface so the allocation of addresses are only available to the private internal network
# cat /etc/sysconfig/dhcpd
# Command line options here
DHCPDARGS=eth0
DHCP client :(Imp files/commands)
/var/lib/dhclient/dhclient-eth0.leases ( To check lease obtained)
[root@Host-DHCP-Client ~]# ps -elf |grep dhclient
1 S root 1509 1 0 75 0 - 1692 - 19:45 ? 00:00:00 /sbin/dhclient -1 -q -lf /var/lib/dhclient/dhclient-eth0.leases -pf /var/run/dhclient-eth0.pid eth0
For Dhcp Client vm.cfg under Hypervisor:
/var/ovs/mount/70B7E79628294FF8A7C92D6EFCD506FA/running_pool/2374_Host-DHCP-Client
Add the below line :
--------------------------------------------------------------
dhcp = "dhcp"
vif = ['bridge=xenbr0,mac=00:16:3E:48:E1:3E,type=netfront']
--------------------------------------------------------------
mac addres is the address of eth0 in dhcp client Host-DHCP-Client
Started vm again
bash$xm create ./vm.cfg
Configuration in DHCP server :
=============================
1) Edit /etc/dhcpd.conf
[aime1@crm-ohs dhcpd]$ cat /etc/dhcpd.conf
ddns-update-style none;
#local7.* /var/log/dhcpd.log;
option domain-name-servers 144.20.190.70, 138.2.202.15, 130.35.249.41;
default-lease-time 86400;
max-lease-time 604800;
authoritative;
subnet 192.168.1.0 netmask 255.255.255.0 {
# interface eth0:1;
range 192.168.1.128 192.168.1.254;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
# option routers 192.168.1.10;
}
[aime1@crm-ohs dhcpd]$
2) start dhcp server
dhcpd eth0
Please Note dhcp runs only on eth0 or eth1 and it wont run on aliases like eth0:1
3) Check the status :
[root@crm-ohs ~]# /etc/rc.d/init.d/dhcpd status
dhcpd (pid 17607) is running...
[root@crm-ohs ~]#
4) Added a (Virtual IP just to check )
$ifconfig eth0:1 192.168.1.10 netmask 255.255.255.0 up
eth0:1 Link encap:Ethernet HWaddr 00:16:3E:41:46:00
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Configuration in DHCP Client :
==============================
1)
[root@Host-DHCP-Client ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Xen Virtual Ethernet
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
[root@Host-DHCP-Client ~]#
2) restart network (or better reboot host)
/etc/rc.d/int.d/network restart
3) Now chekc the Ip obtained is in 192 series :
[root@Host-DHCP-Client ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:16:3E:48:E1:3E
inet addr:192.168.1.254 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::216:3eff:fe48:e13e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:377865 errors:0 dropped:0 overruns:0 frame:0
TX packets:12622 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:91226762 (87.0 MiB) TX bytes:8154809 (7.7 MiB)
====================================
Hypervisor : - Hypervisor-Host
DHCP Client : - Host-DHCP-Client
DHCP Server : Host-DHCP-Server
DHCP server:(Imp files/command)
Config file : /etc/dhcpd.conf
Pid file : : /var/run/dhcpd.pid
The DHCP daemon can be configured with command line options by using the /etc/sysconfig/dhcpd file.
For security, DHCP can be bound to an interface so the allocation of addresses are only available to the private internal network
# cat /etc/sysconfig/dhcpd
# Command line options here
DHCPDARGS=eth0
DHCP client :(Imp files/commands)
/var/lib/dhclient/dhclient-eth0.leases ( To check lease obtained)
[root@Host-DHCP-Client ~]# ps -elf |grep dhclient
1 S root 1509 1 0 75 0 - 1692 - 19:45 ? 00:00:00 /sbin/dhclient -1 -q -lf /var/lib/dhclient/dhclient-eth0.leases -pf /var/run/dhclient-eth0.pid eth0
For Dhcp Client vm.cfg under Hypervisor:
/var/ovs/mount/70B7E79628294FF8A7C92D6EFCD506FA/running_pool/2374_Host-DHCP-Client
Add the below line :
--------------------------------------------------------------
dhcp = "dhcp"
vif = ['bridge=xenbr0,mac=00:16:3E:48:E1:3E,type=netfront']
--------------------------------------------------------------
mac addres is the address of eth0 in dhcp client Host-DHCP-Client
Started vm again
bash$xm create ./vm.cfg
Configuration in DHCP server :
=============================
1) Edit /etc/dhcpd.conf
[aime1@crm-ohs dhcpd]$ cat /etc/dhcpd.conf
ddns-update-style none;
#local7.* /var/log/dhcpd.log;
option domain-name-servers 144.20.190.70, 138.2.202.15, 130.35.249.41;
default-lease-time 86400;
max-lease-time 604800;
authoritative;
subnet 192.168.1.0 netmask 255.255.255.0 {
# interface eth0:1;
range 192.168.1.128 192.168.1.254;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
# option routers 192.168.1.10;
}
[aime1@crm-ohs dhcpd]$
2) start dhcp server
dhcpd eth0
Please Note dhcp runs only on eth0 or eth1 and it wont run on aliases like eth0:1
3) Check the status :
[root@crm-ohs ~]# /etc/rc.d/init.d/dhcpd status
dhcpd (pid 17607) is running...
[root@crm-ohs ~]#
4) Added a (Virtual IP just to check )
$ifconfig eth0:1 192.168.1.10 netmask 255.255.255.0 up
eth0:1 Link encap:Ethernet HWaddr 00:16:3E:41:46:00
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Configuration in DHCP Client :
==============================
1)
[root@Host-DHCP-Client ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Xen Virtual Ethernet
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
[root@Host-DHCP-Client ~]#
2) restart network (or better reboot host)
/etc/rc.d/int.d/network restart
3) Now chekc the Ip obtained is in 192 series :
[root@Host-DHCP-Client ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:16:3E:48:E1:3E
inet addr:192.168.1.254 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::216:3eff:fe48:e13e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:377865 errors:0 dropped:0 overruns:0 frame:0
TX packets:12622 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:91226762 (87.0 MiB) TX bytes:8154809 (7.7 MiB)
No comments:
Post a Comment