Difference between revisions of "DHCP"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
(Set up)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Assumes you have set up vzbr0, as described on [[Virtual Ethernet device]]
+
[[Category: Networking]]
 +
 
 +
The following article describes how to use DHCP from inside a container. Note that it requires [[veth]] device.
 +
 
 +
== Set up ==
 +
Assumes you have set up vzbr0, as described on [[Virtual Ethernet device]].
  
 
<pre>
 
<pre>
  402  vzctl create 144 --ostemplate centos-4-i386-minimal
+
vzctl create 144 --ostemplate centos-4-i386-minimal
  404  vzctl start 144
+
vzctl start 144
  405  vzyum 144 install dhcp
+
vzyum 144 install dhcp
  408  vzctl set 144 --netif_add eth0 --save
+
vzctl set 144 --netif_add eth0 --save
  409  brctl show
+
brctl show
  412  brctl addif vzbr0 veth144.0
+
 
  413  ifconfig vzbr0
+
brctl addif vzbr0 veth144.0
  414  cat /proc/sys/net/ipv4/conf/vzbr0/forwarding  
+
ifconfig vzbr0
  415  cat /proc/sys/net/ipv4/conf/vzbr0/proxy_arp  
+
cat /proc/sys/net/ipv4/conf/vzbr0/forwarding  
  417  echo 1 > /proc/sys/net/ipv4/conf/vzbr0/forwarding  
+
cat /proc/sys/net/ipv4/conf/vzbr0/proxy_arp  
  418  echo 1 > /proc/sys/net/ipv4/conf/vzbr0/proxy_arp  
+
echo 1 > /proc/sys/net/ipv4/conf/vzbr0/forwarding  
 +
echo 1 > /proc/sys/net/ipv4/conf/vzbr0/proxy_arp  
 
</pre>
 
</pre>
  
Line 65: Line 71:
 
</pre>
 
</pre>
  
References:
+
== External links ==
* http://www.cpqlinux.com/dhcpd.html - create static ips, debugging etc.
+
* http://www.cpqlinux.com/dhcpd.html - create static IPs, debugging etc.
 
* http://mailman.vyatta.com/pipermail/vyatta-users/2007-September/001858.html - not configured to listen on any interfaces
 
* http://mailman.vyatta.com/pipermail/vyatta-users/2007-September/001858.html - not configured to listen on any interfaces
 +
* http://forum.openvz.org/index.php?t=msg&goto=22072& - diagnosis
 +
* http://www.google.ca/search?q=DHCPDARGS+brctl - searches for help on getting a virtual bridge to work with DHCPD
 +
* http://www.linuxfoundation.org/en/Net:Bridge - great explanation of bridging

Latest revision as of 10:11, 23 August 2011


The following article describes how to use DHCP from inside a container. Note that it requires veth device.

Set up[edit]

Assumes you have set up vzbr0, as described on Virtual Ethernet device.

vzctl create 144 --ostemplate centos-4-i386-minimal
vzctl start 144
vzyum 144 install dhcp
vzctl set 144 --netif_add eth0 --save
brctl show

brctl addif vzbr0 veth144.0
ifconfig vzbr0
cat /proc/sys/net/ipv4/conf/vzbr0/forwarding 
cat /proc/sys/net/ipv4/conf/vzbr0/proxy_arp 
echo 1 > /proc/sys/net/ipv4/conf/vzbr0/forwarding 
echo 1 > /proc/sys/net/ipv4/conf/vzbr0/proxy_arp 

Instructions largely borrowed from http://oob.freeshell.org/nzwireless/dhcpd.html

Sample DHCPD.conf[edit]

# Sample /etc/dhcpd.conf

# Set DHCPD to answer requests on the wireless interface

DHCPDARGS=wlan0;

# Set some defaults for lease time and DNS update method
ddns-update-style ad-hoc;
default-lease-time 600;
max-lease-time 7200;

# Set the subnet mask for the wireless IP network
option subnet-mask 255.255.255.0;

# Set the Broadcast address. This will be 10.x.x.255,
# the "x.x" will depend upon the network assigned to you by NZWireless.
option broadcast-address 10.1.2.255;

# Set the router address, this will be 10.x.x.1, the address
# of your wireless interface WLAN0
option routers 10.1.2.1;

# Set the Name Server address. This will be the same as your WLAN0 address
# because we intend to run DNS on this machine.
option domain-name-servers 10.1.2.1;

# Set the default domain name for clients on this network.
# i.e. the DNS domain assigned to you by your wireless administrator.
option domain-name "simon.akld.nzwireless.org";

# Allocate a network range for dynamic IP addresses to hand out to clients.
# Again, this range will be in 10.x.x.x, depending upon the network allocated
# to you by your wireless administrator.
subnet 10.1.2.0 netmask 255.255.255.0 {
    range 10.1.2.10 10.1.2.20;
} 
Host$ cp /etc/sysconfig/network /vz/root/144/etc/sysconfig/network
vz144$ service dhcpd start

External links[edit]