Ubuntu how to choose IPv4 or IPv6 channel when using apt-get update

  

Ubuntu can use apt-get to get system or software updates, and download these updates from the network to install on the computer. In fact, Ubuntu users can also choose to download these updates on the IPv4 or IPv6 channel. Here's how to choose IPv4 or IPv6 channels when Ubuntu uses apt-get updates.

ForceIPv4: Global forced to use the IPv4 protocol to download

ForceIPv6: Global forced to use the IPv6 protocol to download

Of course, if you want to use IPv6, then you need operator And router support, and the correct configuration on the operating system.

Method 1: Manually specify

apt-get globally using the IPv4 example

1.sudo apt-get -o Acquire::ForceIPv4=true install pkg

2.sudo apt-get -o Acquire::ForceIPv4=true update

3.sudo apt-get -o Acquire::ForceIPv4=true upgrade

4.sudo apt-get -o Acquire::ForceIPv4=true dist-upgrade

5.sudo apt-get -o Acquire::ForceIPv4=true install XXX

apt-get global IPv6 example

1.sudo apt-get -o Acquire::ForceIPv6=true install pkg

2.sudo apt-get -o Acquire::ForceIPv6=true update

3.sudo apt- Get -o Acquire::ForceIPv6=true upgrade

4.sudo apt-get -o Acquire::ForceIPv6=true dist-upgrade

5.sudo apt-get -o Acquire:: ForceIPv6=true install XXX

Method 2: Configure Bash Alias

If you don't want to lose this time every time, you can directly change the Bash Shell configuration file ~/.bashrc

## makes Using IPv6 ##

#alias apt-get=‘sudo apt-get -o Acquire::ForceIPv6=true’

## Using IPv4 ##

alias Apt-get=‘sudo apt-get -o Acquire::ForceIPv4=true’

Method 3: Create an apt-get configuration file

If you want apt-get to force IPv6 Create the following configuration file

/etc/apt/apt.conf.d/1000-force-ipv6-transport

and fill in the contents of it

Acquire::ForceIPv6 “true”;

If you want apt-get to force IPv4, you can create the following configuration file

etc/apt/apt.conf.d/1000-force-ipv4-transport

and fill in the contents of it

Acquire::ForceIPv4 “true”;

The above is how Ubuntu uses IPv4 or IPv6 channels when updating with apt-get. No choice, then apt-get defaults to downloading update files using the IPv4 protocol.

Copyright © Windows knowledge All Rights Reserved