Networking

Ubuntu Linux 關閉 IPv6

現在預設裝好之後,都會啟用 IPv6,立意很好,但是某些服務會一直產生 error message

修改方式

編輯 /etc/sysctl.conf

vim /etc/sysctl.conf

新增下列

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

關閉 GRUB 的 IPv6 載入

Perform the following steps with root privileges to disable IPv6 in Ubuntu 18.04/16.04 Permanently using grub method.

編輯 /etc/default/grub

sudo vim /etc/default/grub

編輯下列兩行為:

GRUB_CMDLINE_LINUX="ipv6.disable=1"
GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1"

更新 grub 設定

update-grub

重新開機


Ubuntu Desktop 多網卡下使用 Network Manager 變更 route metric

nmcli 變更 metric

sudo nmcli connection modify $connection-name ipv4.route-metric 100
sudo nmcli connection down $connection-name
sudo nmcli connection up $connection-name

參考文章

How to set metric in OS moderated with NetworkManager

nmcli — command-line tool for controlling NetworkManager

2.3. 使用 NETWORKMANAGER 命令行工具 NMCLI


curl 偵測 http2 及壓縮

curl -sI https://j7.lb168.tw/

HTTP/2jjwhuang@u20:~$ curl -sI https://j7.lb168.tw/ | grep HTTP
HTTP/2 200
jjwhuang@u20:~$ curl -sI https://j7.lb168.tw/
HTTP/2 200
server: nginx
date: Wed, 09 Dec 2020 16:17:46 GMT
content-type: text/html; charset=UTF-8
vary: Accept-Encoding
vary: Accept-Encoding, Cookie
link: https://j7.lb168.tw/wp-json/; rel=”https://api.w.org/”
strict-transport-security: max-age=15768000

gip, br, deflate 壓縮

curl -s -I -H 'Accept-Encoding: br,gzip,deflate' https://j7.lb168.tw/

gzip

curl -s -I -H ‘Accept-Encoding: br,gzip,deflate’ https://j7.lb168.tw/
HTTP/1.1 200 OK
Server: nginx
Date: Sat, 26 Dec 2020 14:00:15 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
Vary: Accept-Encoding
Link: https://j7.lb168.tw/wp-json/; rel=”https://api.w.org/”
Strict-Transport-Security: max-age=15768000
Content-Encoding: gzip
curl -s -I -H 'Accept-Encoding: br,gzip,deflate' https://www.cloudflare.com/

br

HTTP/2 200
date: Sat, 26 Dec 2020 14:05:00 GMT
content-type: text/html; charset=utf-8
set-cookie: __cfduid=dfd4f99c00673fb9e171266d72145632b1608991500; expires=Mon, 25-Jan-21 14:05:00 GMT; path=/; domain=.www.cloudflare.com; HttpOnly; SameSite=Lax; Secure
cf-ray: 607b5aaf2e9af071-TPE
age: 10
cache-control: public, max-age=30
strict-transport-security: max-age=31536000
vary: Accept-Encoding
cf-cache-status: HIT
cf-request-id: 0740f701770000f0719a8f9000000001
expect-ct: max-age=604800, report-uri=”https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct”
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
report-to: {“endpoints”:[{“url”:”https:\/\/a.nel.cloudflare.com\/report?s=r6No5T5w1q%2B%2Bqi%2Bi1d5rHIjmQoC9AbwOMJgEHUGKM4RdM7riJNtHRvh1cEwnEoYLRahsl4D%2F1ror%2Bt0SeRUOhx9rh8OuBjkNzm31QzGw8Cxr%2FT4%3D”}],”group”:”cf-nel”,”max_age”:604800}
nel: {“report_to”:”cf-nel”,”max_age”:604800}
server: cloudflare
content-encoding: br

http3 偵測

自己下載 curl 編譯XD


TCP BBR – Google 設計針對 TCP 擁塞的演算法

Linux Kernel 4.9 之後,的都有支援。

參考文獻:

TCP congestion control

TCP擁塞控制

啟用 BBR

echo 'net.core.default_qdisc=fq' >> /etc/sysctl.conf
echo 'net.ipv4.tcp_congestion_control=bbr' >> /etc/sysctl.conf 

重新載入 /etc/sysctl.conf

sudo sysctl -p

檢查是否啟用 BBR

sudo sysctl net.ipv4.tcp_available_congestion_control

結果:

net.ipv4.tcp_available_congestion_control = reno cubic bbr
sudo sysctl net.ipv4.tcp_congestion_control

結果

net.ipv4.tcp_congestion_control = bbr

回到頂端