How setup dhcp in zone:
Create zone config for dhcp-zone:
sudo cat > dhcp.cmd <<EOT
create -b
set zonepath=/zones/dhcp
set brand=dpkg
set autoboot=false
set ip-type=exclusive
add fs
set dir="/export/home/admin"
set special="/export/home/admin"
set type="lofs"
end
add fs
set dir="/export/builds"
set special="/export/builds"
set type="lofs"
end
add net
set physical="iz1"
set global-nic="vsw0"
add property (name=ip,value="192.168.0.1")
add property (name=netmask,value="255.255.255.0")
add property (name=gateway,value="192.168.0.254")
add property (name=primary,value="true")
end
add attr
set name="resolvers"
set type="string"
set value="8.8.8.8"
end
verify
commit
EOT
sudo zonecfg -z dhcp -f dhcp.cmd
sudo zonecfg -z dhcp info
zonename: dhcp
zonepath: /zones/dhcp
brand: dpkg
autoboot: false
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: exclusive
hostid:
fs-allowed:
uuid: 46b79185-7320-4ab6-b700-15058bd49c02
fs:
dir: /export/home/admin
special: /export/home/admin
raw not specified
type: lofs
options: []
fs:
dir: /export/builds
special: /export/builds
raw not specified
type: lofs
options: []
net:
address not specified
allowed-address not specified
defrouter not specified
global-nic: vsw0
mac-addr not specified
physical: iz1
vlan-id not specified
property: (name=ip,value="192.168.0.1")
property: (name=netmask,value="255.255.255.0")
property: (name=gateway,value="192.168.0.254")
property: (name=primary,value="true")
attr:
name: resolvers
type: string
value: 8.8.8.8
sudo zoneadm -z dhcp install
sudo zoneadm -z dhcp boot
sudo mkdir /export/home/admin
sudo zoneadm list -civ
ID NAME STATUS PATH BRAND IP
0 global running / dpkg shared
1 dhcp running /zones/dhcp dpkg excl
2. Install dhcp, setting and start service:
sudo zlogin dhcp
root@dhcp:~# ifconfig
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
iz1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 9000 index 2
inet 192.168.0.1 netmask ffffff00 broadcast 192.168.0.255
ether 2:8:20:92:59:94
lo0: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1
inet6 ::1/128
root@dhcp:~# apt install isc-dhcp-server -y
root@dhcp:~# mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bckp
root@dhcp:~# cat>/etc/dhcp/dhcpd.conf <<EOT
# A slightly different configuration for an internal subnet.
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.100 192.168.0.200;
option subnet-mask 255.255.255.0;
option domain-name-servers 8.8.8.8;
# option domain-name "internal.example.org";
option routers 192.168.0.254;
option broadcast-address 192.168.0.255;
default-lease-time 600;
max-lease-time 7200;
}
EOT
root@dhcp:~# ifconfig
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
iz1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 9000 index 2
inet 192.168.0.1 netmask ffffff00 broadcast 192.168.0.255
ether 2:8:20:92:59:94
lo0: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1
inet6 ::1/128
root@dhcp:~# cat>/etc/default/isc-dhcp-server <<EOT
# Defaults for isc-dhcp-server (sourced by /etc/init.d/isc-dhcp-server)
# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
#DHCPDv4_CONF=/etc/dhcp/dhcpd.conf
#DHCPDv6_CONF=/etc/dhcp/dhcpd6.conf
# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
#DHCPDv4_PID=/var/run/dhcpd.pid
#DHCPDv6_PID=/var/run/dhcpd6.pid
# Additional options to start dhcpd with.
# Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
#OPTIONS=""
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACESv4="iz1"
INTERFACESv6=""
EOT
root@dhcp:~# svcadm enable isc-dhcp-server
root@dhcp:~# svcs -xv
root@dhcp:~# svcs isc-dhcp-server
STATE STIME FMRI
online 10:46:50 svc:/network/isc-dhcp-server:default
root@dhcp:~# dhcp-lease-list
To get manufacturer names please download http://standards.ieee.org/regauth/oui/oui.txt to /usr/local/etc/oui.txt
Reading leases from /var/lib/dhcp/dhcpd.leases
MAC IP hostname valid until manufacturer
===============================================================================================
root@dhcp:~# exit
logout
Create client-zone dhcp:
cat>zone.cmd <<EOT
create
set zonepath=/zones/zone
set autoboot=false
set ip-type=exclusive
add net
set physical=int1
set global-nic="vsw0"
add property (name="ip",value="dhcp")
add property (name="primary",value="true")
end
commit
exit
EOT
sudo zonecfg -z zone -f zone.cmd
sudo zoneadm -z zone install
sudo zoneadm -z zone boot
sudo zoneadm list -civ
ID NAME STATUS PATH BRAND IP
0 global running / dpkg shared
1 dhcp running /zones/dhcp dpkg excl
2 zone running /zones/zone dpkg excl
sudo zlogin -l root dhcp dhcp-lease-list
To get manufacturer names please download http://standards.ieee.org/regauth/oui/oui.txt to /usr/local/etc/oui.txt
Reading leases from /var/lib/dhcp/dhcpd.leases
MAC IP hostname valid until manufacturer
===============================================================================================
02:08:20:a0:5a:92 192.168.0.100 dhcp 2022-11-24 10:20:34 -NA-
sudo zlogin -l root zone ifconfig
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
int1: flags=1004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4> mtu 9000 index 2
inet 192.168.0.100 netmask ffffff00 broadcast 192.168.0.255
ether 2:8:20:a0:5a:92
lo0: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1
inet6 ::1/128
// install pkg for os-test
uname -a
SunOS debug221122 5.11 2.0.3.7-20221122-1-0+int2 i86pc i386 i86pc