Network Tips

Disable IPv6

In Kernel Module (Requires Reboot)

Edit /etc/default/grub and add ipv6.disable=1 to the line GRUB_CMDLINE_LINUX

/etc/default/grub

GRUB_TIMEOUT=5
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="ipv6.disable=1 crashkernel=auto rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

Regenerate a GRUB configuration file and overwrite the existing one

grub2-mkconfig -o /boot/grub2/grub.cfg

Restart the system and verify there is no inet6 line in the ip addr show command output

shutdown -r now

Using sysctl Settings (No Reboot Required)

Append the lines below to /etc/sysctl.conf

/etc/sysctl.conf

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

To make the settings effective, execute

sysctl -p

Note

Make sure the file /etc/ssh/sshd_config contains the line AddressFamily inet

To avoid breaking SSH X forwarding if you are using the sysctl method

Add the AddressFamily line to sshd_config:

/etc/ssh/sshd_config

AddressFamily inet

Restart sshd for changes to get effect

systemctl restart sshd

Use a Different IP Address on a curl Command

To use 127.0.0.1 instead of the real IP address of docs.rda.run

curl --resolve docs.rda.run:443:127.0.0.1 https://docs.rda.run

Download SSL Certificate

echo quit | openssl s_client -servername docs.rda.run -connect docs.rda.run:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > site-cert.pem

To use this cert

curl

curl --cacert site-cert.pem https://docs.rda.run

wget

wget --ca-certificate=site-cert.pem https://docs.rda.run

Verify Network Throughput Between Two Servers

On server 01

iperf3 -s

On server 02

upload speed, Mbits/sec

iperf3 -f m -c <IP_SERVER_01> | grep sender | awk -F " " '{print $7}'

download speed, Mbits/sec

iperf3 -f m -c <IP_SERVER_01> -R | grep sender | awk -F " " '{print $7}'

Running iperf3 as a Service

/etc/systemd/system/iperf3.service

[Unit]
Description=iperf3 server
After=syslog.target network.target

[Service]
ExecStart=/usr/bin/iperf3 -s
Restart=always
RuntimeMaxSec=3600
User=iperf

[Install]
WantedBy=multi-user.target
DefaultInstance=5201
sudo adduser --system --no-create-home -s /sbin/nologin iperf
sudo systemctl daemon-reload
sudo systemctl start iperf3

List All IPv4 Addresses of a Network

nmap -sn 172.17.3.0/24 | grep -B 1 'Host is up' | grep -oE '[[:digit:]]{1,}\.[[:digit:]]{1,}\.[[:digit:]]{1,}\.[[:digit:]]{1,}'

Telnet with Timeout

# echo quit | timeout --signal=9 3 telnet [HOST] [PORT]
$ echo quit | timeout --signal=9 3 telnet rda.run 6969
Trying 172.217.28.14...
Killed

Using curl to Calculate Website Load Time

curl -o /dev/null -s -w %{time_total}\\n https://rda.run
0,536215 # Response (in seconds)

You can get some other info too.

curl -o /dev/null -s -w {time_connect}:%{time_starttransfer}:%{time_total}\\n https://rda.run
# Connection time : transfer start : total time in seconds
0,035299:0,151648:0,157692

Port Redirect on Windows 10

Use PowerShell as admin:

netsh interface portproxy add v4tov4 listenport=80 listenaddress=127.0.0.1 connectport=80 connectaddress=192.168.99.100

To test if the rule was applied:

netsh interface portproxy show all

To remove the rule:

netsh interface portproxy delete v4tov4 listenport=80 listenaddress=127.0.0.1

Resume a curl Download

curl -C - -o partial-file.bin 'www.example.com/caminho/do/partial-file.bin'

Limit syncthing to Only Use Local Network

  • Actions → Settings → Connections: uncheck Enable NAT traversal, Global Discovery, Enable Relaying and Local Discovery
  • Actions → Advanced → Devices: limit the allowed networks to your network only. 192.168.178.0/24, for example
  • Remote Devices → device name → edit → Advanced → Addresses: set tcp://192.168.178.xx:22000, for example
  • Actions → Advanced → Options: uncheck Announce LAN Addresses and Crash Reporting Enabled