IMG 20210607 012944 force Wget to connect to IPv4 or IPv6 addresses

How to Force Wget to connect to IPv4 or IPv6 Addresses

How to Force Wget to connect to IPv4 or IPv6 Addresses? Wget is a free command-line utility that is widely used to download files from the Internet using HTTP, HTTPS, and FTP protocols. It supports IPv4 (Internet Protocol version 4) and IPv6 (Internet Protocol version 6) addresses. To force wget to use IPv4 or IPv6 when downloading files, you must explicitly select it or change the default settings.

This article will teach you how to force Wget to connect to IPv4 or IPv6 addresses when downloading files from the Internet on Linux.

In addition, if your system does not have wget, please do not forget to install wget on your Linux PC or laptop first.

How to Force Wget to connect to IPv4 or IPv6 Addresses

Force Wget to Connect To IPv4 Or IPv6 Addresses

The regular ‘wget <URL>’ command checks all A records in DNS that holds only 32-bit IPv4 address of the given domain and AAAA records in DNS that contains 128-bit IPv6 address.

$ wget https://ftp.gnu.org/gnu/wget/wget-latest.tar.gz

Therefore, wget is likely to connect to IPv6 or IPv4.

The following steps show how to force Wget to connect to IPv4 or IPv6 addresses, or use one of them by default.

Force Wget to Only Use IPv4 Connection

If you want wget to only view and connect to IPv4 addresses, you need to use the “-nite4-only” flag in the wget command, as shown in the figure.

$ wget --inet4-only https://ftp.gnu.org/gnu/wget/wget-latest.tar.gz

When using the above command, wget only checks the IPv4 address in the A record and ignores the IPv6 address in the AAAA record.

Force Wget to Only Use IPv6 Connection

If you want wget to connect and only use IPv6 addresses, you can use the -nite6-only flag to force wget to connect to IPv6 addresses, where A records and IPv4 addresses are ignored.

$ wget –inet6-only https://ftp.gnu.org/gnu/wget/wget-latest.tar.gz

If the host DNS records do not contain an IPv6 address, it will show the error as shown in the below picture.

Force Wget to Connect to Either IPv4 Or IPv6 By Default

In addition to the “-inet4-only” or “-inet6-only” option, you can also use wget to change the default behavior to allow full IPv4 or IPv6 addresses and connect to only one address without prompting every time.

What needs to be done is to set or disable’inet4_only’ in the wget initialization file .wgetrc of /etc/wgetrc (for the entire system for all users) or $HOME/.wgetrc (for one user).

It works exactly the same as “-inet6-only”, where wget forcefully disconnects the IPv4 connection and connects only to the IPv6 host. Similarly, you can add the following line to the global configuration file to disable IPv6 requests and connect to IPv4 only.

Inet6_only = on/off

Set Wget to Use IPv4 or IPv6 by Default

you want wget to always search IPv6 or IPv4 addresses first, you can change the default address selection order.

The only thing you need to do is edit the value of the ‘’–prefer-family’ option in the wget initialization file .wgetrc.

prefer-family=none/IPv4/IPv6

According to the above value, when accessing a host that verifies the domain name of both IPv6 and IPv4 addresses, it will try to connect to the address of the first address system specified, and if it cannot find the address, it will switch to another address.

If the configuration in the host’s DNS entry supports both IPv4 and IPv6, it also helps wget to choose between IPv4 and IPv6.

Final Words

This allows you to organize WGET, if necessary, how to force yourself to include merchandise on the web in Linux or according to the steps above.

More to read:

How to Play Worms Zone on Windows using MEmuplay

How to Protect your Wifi From FragAttacks and Attackers

How to Disable WiFi in Windows 10 Using CMD or Powershell

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: