- Thread Starter
- #26
How do I do that?Assign a static IP address, for example 10.0.0.2/24, to the jail.
Do I need to install a DHCP server (dnsmasq) on my host?
How do I do that?Assign a static IP address, for example 10.0.0.2/24, to the jail.
Starting dhclient.
Starting Network: lo0 epair0b.
lo0: flags=1008049<UP,LOOPBACK,RUNNING,MULTICAST,LOWER_UP> metric 0 mtu 16384
options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x4
groups: lo
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
epair0b: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
options=60001b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,RXCSUM_IPV6,TXCSUM_IPV6>
ether fa:16:3e:2d:ff:20
hwaddr 58:9c:fc:10:d5:2c
inet6 fe80::f816:3eff:fe2d:ff20%epair0b prefixlen 64 scopeid 0x6
groups: epair
media: Ethernet 10Gbase-T (10Gbase-T <full-duplex>)
status: active
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
Waiting 30s for the default route interface: .............................
add host 127.0.0.1: gateway lo0 fib 0: route already in table
add host 127.0.0.1: gateway lo0 fib 0: route already in table
add host 127.0.0.1: gateway lo0 fib 0: route already in table
add host 127.0.0.1: gateway lo0 fib 0: route already in table
add host 127.0.0.1: gateway lo0 fib 0: route already in table
add host 127.0.0.1: gateway lo0 fib 0: route already in table
add host ::1: gateway lo0 fib 0: route already in table
add net fe80::: gateway ::1
add net ff02::: gateway ::1
add net ::ffff:0.0.0.0: gateway ::1
add net ::0.0.0.0: gateway ::1
Assign a static IP address, for example 10.0.0.2/24, to the jail.
You don't need a DHCP server to assign a static IP to a (iocage) jail, the IP address of the jail can be set in two ways:How do I do that?
Do I need to install a DHCP server (dnsmasq) on my host?
Configure an IP address
Code:iocage set ip4_addr="vnet0|10.1.1.10/24" examplejail
- "dhcp": on,
+ "ip4_addr": "x.x.x.x",
Show us /usr/local/etc/dnsmasq.conf, it might be miss-configured.I have installed dnsmasq on the host assuming it would provide an IP address to this jail but it doesn't seem to.
You cannot bridge your jails with your external interface on your VPS. You do need a bridge (to attach your jails to) but it'll be disconnected from your external interface, so this "network" will be entirely local. Then you set up NAT and such so your jails can connect to the outside world.
Internet
|
168.235.83.1
|
+-------------+
| vtnet0 |
|168.235.83.112
+-------------+
|
FreeBSD Host
IP Forwarding
|
+-------------+
| bridge0 |
| 10.0.0.1/24 |
+-------------+
| |
epair0a epair1a
| |
+-----------+ +-----------+
| epair0b | | epair1b |
|10.0.0.2 | |10.0.0.3 |
+-----------+ +-----------+
Jail 1 Jail 2
defaultrouter="168.235.83.1"
gateway_enable="YES"
ifconfig_vtnet0="inet 168.235.83.112/24"
cloned_interfaces="bridge0"
ifconfig_bridge0="inet 10.0.0.1/24 up"
dnsmasq_enable="YES"
wan = "vtnet0"
lan = "bridge0"
nat on $wan from 10.0.0.0/24 to any -> ($wan)
pass in on $lan
pass out keep state
service pf enable service pf start# iocage set bpf=1 <jail>
# iocage set dhcp=1 <jail>
# iocage set vnet=1 <jail>
# iocage set defaultrouter=10.0.0.1 <jail>
defaultrouter="10.0.0.1"
I don’t understand why there is a need for VNET jails.
On my home network I useThe guide in post # 30 was formulated assuming, that the user want's to use a DHCP server to assign a static IP based on the MAC address of the jail (see Thread how-to-get-a-hostname-for-a-jail.103299, post #6). "Host Networking Mode" (IP Sharing) doesn't provide a MAC address, only virtual networks (VNET).
balanga, if that is not the case, please inform us (perhaps I should have asked that earlier).
iocage create -r latest -p ./$JAIL.json -n $JAIL vnet=on dhcp=on On my VPS I have used a static IP. em0 is not relevant there.ifconfig_em0="DHCP"
cloned_interfaces="bridge0"
ifconfig_bridge0="addm em0 up"
Yes. And your jails are bridge(4)d (layer 2) to your LAN. In other words they are on the same broadcast domain.That works fine, presumably because I have a dhcp server (dnsmasq) on my network.
You don't need a DHCP server to assign a static IP to a (iocage) jail, the IP address of the jail can be set in two ways:
Show us /usr/local/etc/dnsmasq.conf, it might be miss-configured.
domain-needed
bogus-priv
no-resolv
no-poll
server=1.1.1.1
server=8.8.8.8
listen-address=168.235.83.112
bind-interfaces
dhcp-range=10.0.0.10,10.0.0.19,12h
cache-size=150
# iocage start TEST
No default gateway found for ipv6.
* Starting TEST
+ Started OK
+ Using devfs_ruleset: 1001 (iocage generated default)
+ Configuring VNET OK
+ Using IP options: vnet
+ Starting services OK
+ Executing poststart OK
+ Acquiring DHCP address: FAILED, address received: ERROR, check jail logs
Stopped TEST due to DHCP failure
ELF ldconfig path: /lib /usr/lib /usr/lib/compat
32-bit compatibility ldconfig path: /usr/lib32
Starting dhclient.
Starting dhclient.
Starting dhclient.
Starting dhclient.
Starting dhclient.
Starting dhclient.
Starting dhclient.
Starting dhclient.
Starting dhclient.
Starting dhclient.
Starting dhclient.
Starting dhclient.
Starting dhclient.
Starting dhclient.
Starting dhclient.
Starting dhclient.
Starting dhclient.
Starting Network: lo0 epair0b.
lo0: flags=1008049<UP,LOOPBACK,RUNNING,MULTICAST,LOWER_UP> metric 0 mtu 16384
<------>options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
<------>inet 127.0.0.1 netmask 0xff000000
<------>inet6 ::1 prefixlen 128
<------>inet6 fe80::1%lo0 prefixlen 64 scopeid 0x4
<------>groups: lo
<------>nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
epair0b: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
<------>options=60001b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,RXCSUM_IPV6,TXCSUM_IPV6>
<------>ether fa:16:3e:2d:ff:20
<------>hwaddr 58:9c:fc:10:d5:2c
<------>inet6 fe80::f816:3eff:fe2d:ff20%epair0b prefixlen 64 scopeid 0x6
<------>groups: epair
<------>media: Ethernet 10Gbase-T (10Gbase-T <full-duplex>)
<------>status: active
<------>nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
Waiting 30s for the default route interface: .............................
add host 127.0.0.1: gateway lo0 fib 0: route already in table
add host 127.0.0.1: gateway lo0 fib 0: route already in table
add host 127.0.0.1: gateway lo0 fib 0: route already in table
add host 127.0.0.1: gateway lo0 fib 0: route already in table
add host 127.0.0.1: gateway lo0 fib 0: route already in table
add host 127.0.0.1: gateway lo0 fib 0: route already in table
add host ::1: gateway lo0 fib 0: route already in table
add net fe80::: gateway ::1
add net ff02::: gateway ::1
add net ::ffff:0.0.0.0: gateway ::1
add net ::0.0.0.0: gateway ::1
Updating motd:.
Creating and/or trimming log files.
Clearing /tmp (X related).
Updating /var/run/os-release done.
Starting syslogd.
Starting cron.
Wed Jul 29 07:43:48 EDT 2026
Starting Network: lo0 epair0b.
lo0: flags=1008049<UP,LOOPBACK,RUNNING,MULTICAST,LOWER_UP> metric 0 mtu 16384
options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x4
groups: lo
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
epair0b: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
options=60001b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,RXCSUM_IPV6,TXCSUM_IPV6>
ether fa:16:3e:2d:ff:20
hwaddr 58:9c:fc:10:d5:2c
inet6 fe80::f816:3eff:fe2d:ff20%epair0b prefixlen 64 scopeid 0x6
groups: epair
media: Ethernet 10Gbase-T (10Gbase-T <full-duplex>)
status: active
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
Waiting 30s for the default route interface: .............................
service dnsmasq restartinterface=bridge0
dhcp-range=10.0.0.10,10.0.0.19,12h
# static jail IPs based on their VNET MAC address
dhcp-host=5a:9c:fc:ff:3e:07,10.0.0.11,jail1
dhcp-host=5a:9c:fc:6a:86:ab,10.0.0.12,www
dhcp-host=58:9c:fc:b0:02:1b,10.0.0.13,Bjail1
Was there something wrong with my config in #37?Your VPS machines /usr/local/etc/dnsmasq.conf is obviously miss-configured.
Assuming only the jails network interfaces should get their IPs from the DHCP server, try the following working configuration from my test VM. I got this minimal dnsmasq.conf setup from the dnsmasq.conf.sample comments, from the manual, and examples from internet search. IPs are changed to your machines IP range. Once the jails get a lease, you can expand the configuration to your needs. See dnsmasq(8) manual and .sample file comments.
Make sure to restart the service after modifying the configuration file:service dnsmasq restart
Code:interface=bridge0 dhcp-range=10.0.0.10,10.0.0.19,12h # static jail IPs based on their VNET MAC address dhcp-host=5a:9c:fc:ff:3e:07,10.0.0.11,jail1 dhcp-host=5a:9c:fc:6a:86:ab,10.0.0.12,www dhcp-host=58:9c:fc:b0:02:1b,10.0.0.13,Bjail1
interface=bridge0
dhcp-range=10.0.0.10,10.0.0.19,12h
# static jail IPs based on their VNET MAC address
#dhcp-host=5a:9c:fc:ff:3e:07,10.0.0.11,jail1
#dhcp-host=5a:9c:fc:6a:86:ab,10.0.0.12,www
#$dhcp-host=58:9c:fc:b0:02:1b,10.0.0.13,Bjail1
#domain-needed
#bogus-priv
#no-resolv
#no-poll
server=1.1.1.1
server=8.8.8.8
listen-address=168.235.83.112
#bind-interfaces
#dhcp-range=10.0.0.10,10.0.0.19,12h
cache-size=150
defaultrouter="168.235.83.1"
gateway_enable="YES"
ifconfig_vtnet0="168.235.83.112/24"
cloned_interfaces="bridge0"
ifconfig_bridge0="inet 10.0.0.1/24 up"
dnsmasq_enable="YES"
iocage start TEST:-* Starting TEST
+ Started OKocage start TEST
+ Using devfs_ruleset: 1001 (iocage generated default)
+ Configuring VNET OK
+ Using IP options: vnet
+ Starting services OK
+ Executing poststart OK
+ DHCP Address: 10.0.0.10/24
Glad to hear.Yipee it works!!!!!
It was my pleasure. I learned a few subjects myself.Especial thanks to T-Daemon for persevering with me.
listen-address=168.235.83.112) instead of the interface that the jails are attach themself to (bridge0).interface=bridge0
# or bridge0 IP address
listen-address=10.0.0.1
# If you want dnsmasq to listen for DHCP and DNS requests only on
# specified interfaces (and the loopback) give the name of the
# interface (eg eth0) here.
# Repeat the line for more than one interface.
#interface=
# Or you can specify which interface _not_ to listen on
#except-interface=
# Or which to listen on by address (remember to include 127.0.0.1 if
# you use this.)
#listen-address=
Not sure I'm following here, there's probably something I'm missing, but what do you mean you cannot bridge a jail to an external interface?You cannot bridge your jails with your external interface on your VPS. You do need a bridge (to attach your jails to) but it'll be disconnected from your external interface, so this "network" will be entirely local. Then you set up NAT and such so your jails can connect to the outside world.
-> cat /etc/rc.conf
(...)
vlans_igb0="10 40 50 60 70 80"
cloned_interfaces="bridge10 bridge40 bridge50 bridge60 bridge70 bridge80"
ifconfig_bridge10="SYNCDHCP addm igb0.10 stp igb0.10 up"
ifconfig_bridge10_ipv6="inet6 auto_linklocal accept_rtadv"
ifconfig_bridge40="addm igb0.40 stp igb0.40 up"
ifconfig_bridge50="addm igb0.50 stp igb0.50 up"
(etc. for other bridges)
ifconfig_igb0_10="up"
ifconfig_igb0_40="up"
(etc. for other VLAN interfaces)
ifconfig_igb0="up"
bridge10 being the one the jail host itself networks on. One thing that is very important here, balanga, is that any interface that goes on a bridge must itself not have an IP configuration, as otherwise the setup will not work. Notice that I want my jail host to network on my VLAN 10, so I assign an IP configuration to bridge10, not to the igb0.10 corresponding VLAN interface; additionally, I have no need for my jail host to network on my VLAN 40, so I don't assign any IP configuration to bridge40, and that itself does not prevent jails attached to that bridge to network themselves on that VLAN.igb or a virtual one such as vtnet, etc.; in all of those cases, the resulting configuration would always look very similar to the above, e.g.:cloned_interfaces="yourbridge"
ifconfig_yourbridge="SYNCDHCP addm vtnet0 stp vtnet0 up"
ifconfig_vtnet0="up"
bridge10 interface. How that is accomplished is heavily dependent on the inner workings of the chosen jail manager; but, in any case, what they essentially do upon booting up the jail is create an epair(4) interface, with its regular a & b terminals, and attach terminal a to the chosen bridge (basically an ifconfig yourbridge addm instruction behind the scenes) and assign terminal b to the jail.jail.conf file somewhere on your filesystem (e.g. for Bastille that's usually at /usr/local/bastille/jails/$jailName/jail.conf and for iocage it should be at /var/run/iocage-$jailName.conf), and they look more or less like this:$jailName {
# networkng unrelated settings:
enforce_statfs = 2;
devfs_ruleset = 13;
exec.clean;
exec.consolelog = /usr/local/bastille/logs/$jailName_console.log;
exec.start = '/bin/sh /etc/rc';
exec.stop = '/bin/sh /etc/rc.shutdown';
host.hostname = $jailName;
mount.devfs;
mount.fstab = /usr/local/bastille/jails/$jailName/fstab;
path = /usr/local/bastille/jails/$jailName/root;
securelevel = 2;
osrelease = 14.4-RELEASE-p7;
# networking settings:
vnet;
vnet.interface = $epairBName;
exec.prestart += "epair0=\$(ifconfig epair create) && ifconfig \${epair0} up name $epairAName && ifconfig \${epair0%a}b up name $epairBName";
exec.prestart += "ifconfig $yourBridge addm $epairAName";
exec.prestart += "ifconfig $epairAName ether $macA";
exec.prestart += "ifconfig $epairBName ether $macB";
exec.prestart += "ifconfig $epairAName description \"vnet0 host interface for Bastille jail $jailName\"";
exec.poststop += "ifconfig $epairAName destroy";
}
jail.conf file should you want to do some manual experimentation.vnet option shown above.vnet jails without DHCP and utilize manual IP configurations for each of them, and you'd do that with ifconfig instructions inside the jail's /etc/rc.conf file very similar to those that you'd use on the host (the rc.conf(5) man page is also a very handy read). The jail managers usually do this for you, but this is essentially what the result would look like:# For a DHCP jail
ifconfig_$epairBName_name="vnet0"
ifconfig_vnet0="SYNCDHCP"
ifconfig_vnet0_ipv6="inet6 -ifdisabled accept_rtadv"
ifconfig_vnet0_descr="jail interface for $yourBridge"
# For a static IP jail
ifconfig_$epairBName_name="vnet0"
ifconfig_vnet0="$yourIP/$yourNetmask up"
ifconfig_vnet0_ipv6="inet6 -ifdisabled accept_rtadv"
ifconfig_vnet0_descr="jail interface for $yourBridge"
vnet is very useful for a multitude of cases because it gives a jail its own, full-blown private networking stack, rather than sharing networking with the jail host.vnet or not, then obviously you need a fair amount of networking knowledge to produce a working configuration, both for the jails and their host.igb0.$tag VLAN interfaces in my own setup, or the vtnet0 interface in the example above, etc.), whether that interface itself has access to the world outside of your jail host, whether the latter is a private network with egress firewalling, etc., etc.Hi balanga ,jmpalacios thank you for your information, but most of it is way beyond my skill level and have no idea what to make of it and it far too complicated for my simple requirements. I am simply an old fashioned hacker, hacker in terms of computer enthusiast rather than anything else.
For the time being I have managed, with the help of some very knowledgeable people on this forum, to achieve what I wanted.
As for iocage, I am very pleased with it and don't understand people's criticisms of it. It seems to do what I want and seems relatively easy to set up once you figure out how to setup VNET.
Hopefully your post will help others who have a more complicated setup than mine.
Try reading what I wrote. I didn't say it was impossible, or that you should never do that. I was specifically talking about balanga 's VPS, its external interface is connected to the hoster's network, he only has one external IP address. You DO NOT bridge your jails to that.but what do you mean you cannot bridge a jail to an external interface?
Today I learned that iocage had been absorbed into the FreeBSD organization, thanks for bringing that to my attention!jmpalacios re iocage, I'd just like to draw your attention to a few pages.
![]()
GitHub - freebsd/iocage: A FreeBSD jail manager
A FreeBSD jail manager. Contribute to freebsd/iocage development by creating an account on GitHub.github.com
This shows that there are 81 contributors, admittedly it is difficult to tell if any of them are currently maintaining or developing it, but there was plenty of activity last month.
In any case, I quite like it and don't see a compelling reason to change.