Skip to content

Instantly share code, notes, and snippets.

@Fartomy
Created November 6, 2025 19:45
Show Gist options
  • Select an option

  • Save Fartomy/c3cba4dc788a1c9f08ae1819bd3d8c33 to your computer and use it in GitHub Desktop.

Select an option

Save Fartomy/c3cba4dc788a1c9f08ae1819bd3d8c33 to your computer and use it in GitHub Desktop.
About Internet Connections
#!/bin/bash
IFACE="enp3s0" # Ağ arayüzünüzü öğrenmek için: ip link show veya ip a
DOWNLINK="95mbit" # Gerçek indirme hızınızın %85-95'i olarak ayarlayın
UPLINK="10mbit" # Gerçek yükleme hızınızın %85-95'i olarak ayarlayın
# Yükleme şekillendirme (kolay)
sudo tc qdisc replace dev $IFACE root cake bandwidth $UPLINK
# İndirme şekillendirme (IFB gerektirir)
sudo modprobe ifb
# Mevcut ifb0 varsa kaldır
sudo ip link del ifb0 2>/dev/null
# ifb0 oluştur ve yapılandır
sudo ip link add ifb0 type ifb
sudo ip link set dev ifb0 up
# Mevcut ingress qdisc varsa kaldır
sudo tc qdisc del dev $IFACE ingress 2>/dev/null
# Ingress qdisc ve filtre ekle
sudo tc qdisc add dev $IFACE handle ffff: ingress
sudo tc filter add dev $IFACE parent ffff: protocol all u32 match u32 0 0 action mirred egress redirect dev ifb0
# ifb0'a CAKE uygula
sudo tc qdisc replace dev ifb0 root cake bandwidth $DOWNLINK
#!/bin/bash
# Args
DOMAIN=$1
DNS_FILE=$2
OUT_FILE=${3:-dns_results.txt} # default if not provided
# Validate args
if [ -z "$DOMAIN" ] || [ -z "$DNS_FILE" ]; then
echo "Usage: $0 <domain> <dns_servers_file> [output_file]"
exit 1
fi
if [ ! -f "$DNS_FILE" ]; then
echo "Error: File '$DNS_FILE' not found"
exit 1
fi
START_TS=$(date +%s)
# Temp file to collect (time_ms, ip, status) tuples
TMP_RESULTS=$(mktemp)
# Header for stdout (use explicit format string)
printf "%s\n" "IP address | Response time"
printf "%s\n" "-----------------|--------------"
# Read DNS file
while IFS= read -r LINE || [ -n "$LINE" ]; do
# Trim leading/trailing whitespace
LINE="${LINE#"${LINE%%[![:space:]]*}"}"
LINE="${LINE%"${LINE##*[![:space:]]}"}"
# Skip empty or full-line comments
[[ -z "$LINE" || "$LINE" =~ ^# ]] && continue
# Strip inline comments (everything after first '#')
LINE="${LINE%%#*}"
# Trim again
LINE="${LINE#"${LINE%%[![:space:]]*}"}"
LINE="${LINE%"${LINE##*[![:space:]]}"}"
[[ -z "$LINE" ]] && continue
IP="$LINE"
# Basic IPv4 pattern
if ! [[ "$IP" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; then
printf "%-16s | %s\n" "$IP" "skipped (not IPv4)"
echo "999999 $IP skipped" >> "$TMP_RESULTS"
continue
fi
# Run dig; cap timeouts; extract integer milliseconds
TIME_MS=$(dig "$DOMAIN" @"$IP" +stats +time=2 2>/dev/null | awk '/Query time:/ {print $4}' | head -n1)
# Ensure TIME_MS is an integer
if ! [[ "$TIME_MS" =~ ^[0-9]+$ ]]; then
printf "%-16s | %s\n" "$IP" "timeout/failure"
echo "999999 $IP timeout/failure" >> "$TMP_RESULTS"
else
printf "%-16s | %s ms\n" "$IP" "$TIME_MS"
echo "$TIME_MS $IP ok" >> "$TMP_RESULTS"
fi
done < "$DNS_FILE"
# Sort results by time ascending and write to OUT_FILE
{
printf "%s\n" "IP address | Response time"
printf "%s\n" "-----------------|--------------"
# successes first
awk '$1 != 999999' "$TMP_RESULTS" | sort -n -k1,1 | awk '{printf "%-16s | %s ms\n", $2, $1}'
# failures
awk '$1 == 999999' "$TMP_RESULTS" | awk '{printf "%-16s | %s\n", $2, "timeout/failure"}'
} > "$OUT_FILE"
END_TS=$(date +%s)
ELAPSED=$((END_TS - START_TS))
printf "%s\n\n" "Sorted results written to: $OUT_FILE"
printf "Time: %02dh:%02dm:%02ds\n" $((ELAPSED/3600)) $(((ELAPSED%3600)/60)) $((ELAPSED%60))
# Cleanup
rm -f "$TMP_RESULTS"
# Windows İçin
- New-NetQosPolicy -Name "Upload" -ThrottleRateActionBitsPerSecond 20MB # Upload hızınızın %85-95'i
- New-NetQosPolicy -Name "LowLatency" -IPProtocolMatchCondition UDP -PriorityValue8021Action 6
- Download için NetLimiter, cFosSpeed, TMeter gibi üçüncü parti yazılım indirmeniz gerekli.
- Silmek isterseniz: Remove-NetQosPolicy -Name "Upload"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment