Ubuntu Networking – Fix Extremely Slow Internet Connection on Ubuntu 16.04 Minimal

networkingUbuntu

I have a server on Hetzner that running Ubuntu 16.04 minimal.

The issue is a slow connection to external sources. When I'm trying to ping everything looks fine. But when I'm trying to retrieve files from git server (Bitbucket) it takes ages.

The situation gets worse when I'm trying to request using Python Interpreter.
Here are the results:
command results

When I wrote to support about this issue, they requested mtr results so I'm adding those too:mtr

List of current rules:

qdisc mq 0: root 
 Sent 188170970 bytes 419951 pkt (dropped 0, overlimits 0 requeues 44) 
 backlog 0b 0p requeues 44 
qdisc pfifo_fast 0: parent :1 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
 Sent 50287079 bytes 107135 pkt (dropped 0, overlimits 0 requeues 8) 
 backlog 0b 0p requeues 8 
qdisc pfifo_fast 0: parent :2 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
 Sent 44682112 bytes 105143 pkt (dropped 0, overlimits 0 requeues 13) 
 backlog 0b 0p requeues 13 
qdisc pfifo_fast 0: parent :3 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
 Sent 47973033 bytes 104060 pkt (dropped 0, overlimits 0 requeues 6) 
 backlog 0b 0p requeues 6 
qdisc pfifo_fast 0: parent :4 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
 Sent 45228746 bytes 103613 pkt (dropped 0, overlimits 0 requeues 17) 
 backlog 0b 0p requeues 17

Can anybody please help me to resolve the issue?

Best Answer

I've found the cause of the issue. The slow connection was because of IPv6 configuration. When I disabled IPv6, everything worked fine.

$ sudo nano /etc/sysctl.conf

Added these configurations at the end of file:

# IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Then restarted sysctl.conf:

$ sudo sysctl -p
Related Question