FreeBSD Jail Add Multiple IPv4 / IPv6 Address

How do I add multiple IPv4 / Ipv6 inside jail?

FreeBSD does support Multi-IPv4/v6/no-IP jail and it was merged to STABLE release. You need to rebuild your kernel including jls(8) and to use the new features jail(8), jexec(8) and cpuset(1) with a new kernel. Another option is get FreeBSD 7.2 (RC1 or above) using cvsup, just do make buildworld. Here is what you need to put in /etc/rc.conf file for Multi-IPv4/v6/no-IP jail configuration for httpd jail (note there are 3 ips defined):

ADVERTISEMENTS

jail_enable="YES"
jail_list="httpd"
jail_httpd_rootdir="/iscsi/httpd"     # jail's root directory
jail_httpd_hostname="web01.cyberciti.com"  # jail's hostname
jail_httpd_ip="10.24.55.106,74.86.48.99,2607:f0d0:1002:11::4" # jail's multi IPs address
jail_smtpd_devfs_enable="YES"          # mount devfs in the jail
jail_smtpd_devfs_ruleset="devfsrules_jail" # devfs ruleset to apply to jail

Save and close the file. Restart jail service:
# /etc/rc.d/jail restart
To verify multiple IP, enter:
# jls -v
Sample output:

   JID  Hostname                      Path
        Name                          State
        CPUSetID
        IP Address(es)
     2  web01.cyberciti.com           /iscsi/httpd
                                      ALIVE
        2     
        10.24.55.106   
        74.86.48.99  
        2607:f0d0:1002:11::4

From the man page:

jail_httpd_ip is used to set to the primary IPv4 and/or IPv6 addresses assigned to the jail. The argument can be a sole address or a comma separated list of addresses. Additionally each address can be prefixed by the name of an interface followed by a pipe to overwrite jail__interface or jail_interface and/or suffixed by a netmask, prefixlen or prefix. In case no netmask, prefixlen or prefix is given, /32 will be used for IPv4 and /128 will be used for an IPv6 address. If no address is given for the jail then the jail will be started with no networking support.

This entry is 3 of 6 in the FreeBSD Jail Operating System-level Virtualization Tutorial series. Keep reading the rest of the series:
  1. Setup FreeBSD Jail With ezjail
  2. FreeBSD Jail Allow Ping / tracerouter Commands
  3. FreeBSD Jail Add Multiple IPv4 / IPv6 Address
  4. FreeBSD Jail Access Private Network Via NAT and PF
  5. How To Upgrade FreeBSD Jail ( OS Level Virtualization )
  6. FreeBSD Jail Allow Sound And Flash Access
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
3 comments… add one
  • juliano Jul 2, 2009 @ 22:58

    Eu gostaria de saber tudo sobre IPV4,IPV6 e shell que se refere ao curso de manuteção de computadores

  • John Oct 24, 2009 @ 16:52

    @juliano Why the heck do you comment in SPANISH on an ENGLISH post? Just plain annoying.

  • nbari Aug 11, 2011 @ 19:54

    @John it is portuguese not spanish

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.