# How to configure a jail to only use IPv4



## byrnejb (Sep 6, 2019)

I have a problem with a jail trying to update and install gems from rubygem.org.  Apparently this is some problem with IPv6.  The Gem utility is reported to  prefe IPv6 if it is available. I would like to configure the jail to only use ipv4 and avoid this if this turns out to be the problem.  The jail is configured only with an IPv4 address.  The Host has IPv6 enabled.  I have looked at ail(8) and rc.conf(5) but cannot find a switch or parameter that turns ipv6 off.  How does one turn off ipv6 in a jail without impacting the host?


----------



## SirDice (Sep 6, 2019)

byrnejb said:


> I would like to configure the jail to only use ipv4 and avoid this if this turns out to be the problem.


It's not. 



byrnejb said:


> How does one turn off ipv6 in a jail without impacting the host?


Don't configure it. 

I suspect your analysis is wrong and there's something else not configured correctly. What are the exact error messages you're getting?

Case in point:

```
root@molly:~ # jls
   JID  IP Address      Hostname                      Path
     1  192.168.10.202  j-ports.dicelan.home          /jails/j-ports
```
The host uses both IPv6 and IPv4, this jail only uses IPv4.


----------



## byrnejb (Sep 6, 2019)

Well, the fix was to add all of the ipv4 addresses for `rubygem.org` into the jail's `/etc/hosts` file.


----------



## SirDice (Sep 9, 2019)

That might indicate that you have an issue with /etc/resolv.conf in the jail. Did you copy it from the host? The host might be configured to use IPv6 DNS addresses, which won't work inside an IPv4 only jail.


----------



## byrnejb (Sep 9, 2019)

There was no problem with resolv.conf.  The issue is some incompatibility with ipv6 at RubyGem.org.  The issue has been widely reported.  I just was not current.


----------



## SirDice (Sep 9, 2019)

byrnejb said:


> The issue is some incompatibility with ipv6 at RubyGem.org.


But you're not using IPv6? Not on your jail at least. So why would it have a problem?


----------



## byrnejb (Sep 9, 2019)

Good question.  I do not have an answer.  Not everybody using ipv6 encounters it.  Some people have solved this issue for themselves by disabling ipv6 on affected Linux systems.   But one of the recommended workarounds is do do as I have done and place all the rubygem.org ipv4 addresses in /etc/hosts. Some folks have speculated that the problem is with the Ruby Gem utility itself.


----------

