# Possibility to create a kernel without IPv6?

## WvR

Environment: university computer network with high capacity internet connection.

Since more than a year, I have noticed a problem with internet connections at work, which seems to only affect linux PCs. The symptoms are simple: it takes a long time to set up a connection to a website; once the website has been contacted the data is downloaded quickly. WIth Windows machines there is absolutely no problem.

Downloading software packages for Gentoo updates is also excruciatingly slow. Here I noticed the following pattern:

- the download server is accessed with an IPv6 address, which always times out

- then the next server is tried with IPv6 and times out

- repeat until servers exhausted

When I set GENTOO_MIRRORS, the process is as follows:

- the GENTOO_MIRROR is accessed with IPv6, which times out

- when the IPv6 times out, portage tries again with IPv4 address, which works immediately

I have a feeling that something is going with our network servers (the university is behind a big firewall, with very few open ports). Perhaps the university servers somehow do not like IPv6.

Thus, I thought it might be worthwhile to test whether things are better if I disable IPv6 in Gentoo. But..... is that possible? Or is there an easy way (perhaps in a configuration file) to tell network applications to prefer IPv4 over IPv6?

----------

## Ant P.

Add this to make.conf to disable IPv6 in portage (the manpage doesn't say when the backslashes are required, so try removing those if it doesn't work):

```
FETCHCOMMAND='wget --inet4-only -t 3 -T 60 --passive-ftp -O "\${DISTDIR}/\${FILE}" "\${URI}"'
```

Or just add inet4-only to /etc/wgetrc to make it global. Browsers shouldn't need extra configuration.

----------

## mike155

If you don't need IPv6 at all, you could boot Linux with kernel option 'ipv6.disable=1'.

----------

## krinn

like mike155 said but also two other choices:

temp disable it but you have boot with ipv6 kernel and ipv6 up

```
echo 1 > /proc/sys/net/ipv6/conf/eth0/disable_ipv6
```

or build a kernel without ipv6 support

```
# CONFIG_IPV6 is not set
```

----------

## WvR

 *Ant P. wrote:*   

> Add this to make.conf to disable IPv6 in portage (the manpage doesn't say when the backslashes are required, so try removing those if it doesn't work):
> 
> ```
> FETCHCOMMAND='wget --inet4-only -t 3 -T 60 --passive-ftp -O "\${DISTDIR}/\${FILE}" "\${URI}"'
> ```
> ...

 

I set 

prefer-family = IPv4

in /etc/wgetrc and that really improves performance on emerge-webrsync etc. So that is already a good start! I will also try the other suggestions to prefer IPv4 for other network applications.

----------

## WvR

 *krinn wrote:*   

> like mike155 said but also two other choices:
> 
> temp disable it but you have boot with ipv6 kernel and ipv6 up
> 
> ```
> ...

 

In menuconfig:

Networking Support -> Networking options -> The IPv6 Protocol -> should I simply de-select everything here?

----------

## mike155

 *Quote:*   

> should I simply de-select everything here?

 

If you want to go that way: don't de-select options inside of 'Networking Support -> Networking options -> The IPv6 Protocol'. De-select 'Networking Support -> Networking options -> The IPv6 Protocol' itself.

----------

## WvR

 *mike155 wrote:*   

> If you want to go that way: don't de-select options inside of 'Networking Support -> Networking options -> The IPv6 Protocol'. De-select 'Networking Support -> Networking options -> The IPv6 Protocol' itself.

 

But it seems that it is not possible to de-select "The IPv6 Protocol" in its entirety.

For now, I have used the trick to disable to IPv6 protocol via /sys/proc/... and that is already greatly improving the situation. For now, I think I will just wait and see where we go from here.

----------

## Chiitoo

 *WvR wrote:*   

> But it seems that it is not possible to de-select "The IPv6 Protocol" in its entirety.

 

It appears to be forcefully enabled in cases where

```
GENTOO_LINUX_INIT_SYSTEMD [=y] && GENTOO_LINUX [=y] && GENTOO_LINUX_UDEV [=y]
```

is true.

----------

## gengreen

Unrelated to the main question but as I also remove the ipv6 support from whenever I can, add the useflag -ipv6 to your make.conf can be useful.

----------

## turtles

I would guess in 2018 most Gentoo users are on a network that does not use IPV6 at all.

I have no problem with the idea of IPV6 it sounds great.

But somehow on Gentoo systems DNS first queries IPV6 waits for a timeout then uses IPV4, this slows my internet down to a crawl.

DNS on Gnu/Linux seems to prefer IPV6, and in my experience Linux software gets buggy with IPV6 not compiled in. 

I would try this first:

 *mike155 wrote:*   

> If you don't need IPv6 at all, you could boot Linux with kernel option 'ipv6.disable=1'.

 

That works well for me, no need to have use flags or kernel compiled without IPV6.

No special settings to remember etc..

On other nix systems I was able to fix this DNS preference for IPV6 in 

```
/etc/gai.conf
```

By adding something like:

```

scopev4 ::ffff:169.254.0.0/112  2

scopev4 ::ffff:127.0.0.0/104    2

scopev4 ::ffff:0.0.0.0/96       14

```

And there may be a way to disable IPV6 for DNS completely in that file?

Someone might chime in here with that.

Cheers

----------

