jail -c host.hostname=my-jail exec.start=lovelyappWhy don't you consult the sysutils/iocage documentation (no offense, but it's not the first time you don't)? If I'm unfamiliar with a program, I look in the documentation, if available, online, and local installed manuals.am using IOCAGE to manage jails
https://iocage.readthedocs.io/en/latest/networking.html#configuring-network-interfaces .have no idea how IP address are allocated or ir they can be pre-configured in some way
Networking
Jails have multiple networking options to better serve a user’s needs.Traditionally, jails have only supported IP alias based networking. Thisis where an IP address is assigned to the host’s interface and then usedby the jail for network communication. This is typically known as“shared IP” based jails.
Another recently developed option is called VNET or sometimes VIMAGE.VNET is a fully virtualized networking stack which is isolated per jail.VNET abstracts virtual network interfaces to jails, which then behave inthe same way as physical interfaces.
By default, iocage does not enable VNET, but users can enable andconfigure VNET for a jail by configuring that jail’s properties usingthe instructions in the Configure a Jail section of thisdocumentation.
The rest of this section shows more depth of the Shared IP andVNET networking options, along with instructions forConfiguring Network Interfaces.
I use dnsmasq as a dhcp server
To create a a jail with a DHCP interface add the dhcp=on property:
# iocage create -r 11.0-RELEASE --name myjail dhcp=on
The dhcp=on property implies creating a VNET virtual network stack and enabling the Berkley Packet Filter. DHCP cannot work without VNET. More information about VNET is available in the VNET(9) FreeBSD manual page.
would like to know whether there is any way to assign a hostname to a jail.
EXAMPLES
Create first jail:
iocage create -r 11.0-RELEASE -n myjail
iocage set command:# icoage set host_hostname=<hostname> myjail
All in the iocage documentation.I was looking for a way to assign a hostname at the time of creating the jail, but didn't see it.
iocage create -r 15.1-RELEASE -n myjail
iocage create -r 15.1-RELEASE -n myjail host_hostname=<hostname>
Sure, assuming dnsmasq(8),Is it possible to use dnsmasq to provide a hostname.
--dhcp-host, you have to use vnet in iocage jails to get network interface MAC addresses, see "Tips for Configuring VNET":Force iocage to regenerate the MAC and HW address (e.g.: after cloning a jail). This will cause the MAC and HW addresses to be regenerated when the jail is next started.
# iocage set vnet0_mac=none examplejail
defaultrouter="192.168.1.1"
cloned_interfaces="bridge0"
ifconfig_bridge0="inet 192.168.1.2/24 addm em0"
ifconfig_em0="up"
service netif restart# iocage create -r 15.1-RELEASE -n myjail bpf=1 dhcp=1 vnet=1
# iocage set bpf=1 jail1
# iocage set dhcp=1 jail1
# iocage set vnet=1 jail1
# iocage start jail1
# iocage get vnet0_mac jail1
5a9cfcff3e06 5a9cfcff3e07
# iocage stop jail1
dhcp-host in /usr/local/etc/dnsmasq.conf:dhcp-host=5a:9c:fc:ff:3e:07,192.168.1.15,jail1
service dnsmasq restartroot@iocage-test:~ # iocage start jail1
No default gateway found for ipv6.
* Starting jail1
+ Started OK
+ Using devfs_ruleset: 1000 (iocage generated default)
+ Configuring VNET OK
+ Using IP options: vnet
+ Starting services OK
+ Executing poststart OK
+ DHCP Address: 192.168.1.15/24
root@iocage-test:~ # iocage list -l
+------+-------+------+-------+------+--------------+-----------------------+-----+----------+----------+
| JID | NAME | BOOT | STATE | TYPE | RELEASE | IP4 | IP6 | TEMPLATE | BASEJAIL |
+======+=======+======+=======+======+==============+=======================+=====+==========+==========+
| 8 | jail1 | off | up | jail | 15.1-RELEASE | epair0b|192.168.1.15 | - | - | no |
+------+-------+------+-------+------+--------------+-----------------------+-----+----------+----------+
root@jail1: ~ # ifconfig epair0b
epair0b: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
options=200019<RXCSUM,VLAN_MTU,VLAN_HWTAGGING,RXCSUM_IPV6>
ether 5a:9c:fc:ff:3e:07
hwaddr 58:9c:fc:10:83:fd
inet 192.168.1.15 netmask 0xffffff00 broadcast 192.168.1.255
inet6 fe80::589c:fcff:feff:3e07%epair0b prefixlen 64 scopeid 0x6
groups: epair
media: Ethernet 10Gbase-T (10Gbase-T <full-duplex>)
status: active
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>