Force apt-get to use IPv4 or IPv6 on Ubuntu

Occasionally I have found myself unable to install updates after a fresh Ubuntu server install because running apt-get update or apt-get upgrade hangs when attempting to resolve the IPv6 address of the update repos. It seems it defaults to IPv6, instead of IPv4… but I guess that’s the price you pay for trying to usher the future in. I don’t mind 🙂

This hasn’t been an issue with any other IPv6-compatible devices, such as my Android phone or Windows PCs/VMs, and frankly it’s not important enough to diagnose and fix, since my IPv6 network is used only for browsing, and barely at that. Here’s a quick workaround that forces IPV4 connectivity through apt-get on a temporary or a permanent basis:

Temporary/one time use:

~$ apt-get -o Acquire::ForceIPv4=true <rest of commands go here>

example:

~$ apt-get -o Acquire::ForceIPv4=true update

The above command will run an apt-get update command while forcing IPv4 DNS resolution.

 

To make this change permanent, a new file must be created in /etc/apt/apt.conf.d/:

sudoedit /etc/apt/apt.conf.d/99force-ipv4

Enter the following in the editor:

Acquire::ForceIPv4 "true";

Press Ctrl-O to save the file, confirm, and press Ctrl-X to exit the editor. No reboot necessary – the next time apt-get runs, it will default to IPv4.

If you’d like to enforce IPv6 DNS resolution instead of IPv4, change the entries above from a 4 to a 6.

Sandstorm behind HAProxy in pfSense via SSL Passthrough (TLS SNI extension)

This scenario provides step-by-step instructions on running a Sandstorm server behind an HAProxy reverse proxy so we can make use of SNI and host multiple  domains on a single IP. HAProxy here does not do anything more than route SSL connections to the proper server. All SSL encryption and decryption occurs on the destination server. This… Continue reading Sandstorm behind HAProxy in pfSense via SSL Passthrough (TLS SNI extension)

Clone ESXi USB flash drive to another internal or external boot device – SUCCESSFULLY!

In the home lab, the primary ESXi 6.0 host boots off a cheap 1GB USB flash drive. I think I bought a few of them as a bundle of 5 for $10-20 a while back to use as throwaway drives. The reasons I want to clone this drive to another one: For safekeeping/backup in the… Continue reading Clone ESXi USB flash drive to another internal or external boot device – SUCCESSFULLY!