###### tags: `Linux`, `SRE` # SRE 讀書會 Round 4 #14 - 線上讀書會共筆 ## 活動資訊 * Date: 2020/10/22 (四) 20:00 - 21:30 * [導讀進度表](https://docs.google.com/spreadsheets/d/1Lgti3mILkvwxyzklX1vvLraaGD-7ePK9rkmlulfOknE/edit#gid=0) * [導讀 Guideline](https://study-area.sre.tw/GuideLine/) * Github: [study-area-docs](https://github.com/cross-community/study-area-docs) --- # 現場共筆 ## 41 | 案例篇:如何優化 NAT 性能?(上) 8 Kyle ## 42 | 案例篇:如何優化 NAT 性能?(下) 22 Kyle 網路延遲時:路由,網路封包分析, NAT: - 1. 將IP改寫,用來解決外部ip不夠的問題(public ip) - 2. 支持TCP lb - 3. 內部外部ip mapping NAT TYPE: - 1. Full cone NAT: - ![](https://i.imgur.com/yr1KkK4.png) - 2. Address-restricted cone NAT - 3. sym... - ![](https://i.imgur.com/QFORnTB.png) NAT 映射類型 - 靜態 - 動態 - NAPT - SNAT - DNAT - 雙向地址轉換,同時使用 SNAT 和 DNAT Packet flow in Netfilter and General Networking : iptable經典圖 ![](https://i.imgur.com/kw6jPij.png) iptable nat chain: - prerouting - postrounting - output [Masquerade 補充](https://youtu.be/DGUSFVEvTio) * SNAT: 內主動發起 * Status * conntrack * DNAT: 外部主動 * Status * conntrack 直接改 封包,沒有剝一層 如果是 Tunning 的話,會基於封包再加一層 Header * https://medium.com/@rakeshkanagaraj1990/aws-nat-instance-bb0911ba19d5 * https://shazi.info/%E5%88%A9%E7%94%A8ssh-proxycommand%E5%8F%8Anc%E5%81%9A%E8%B7%B3%E6%9D%BF%E7%9A%84%E9%80%A3%E7%B7%9A%E6%87%89%E7%94%A8/ ``` Host customer Hostname customer.whatever.com <–跳板主機要能正確解析hostname才行,否則請填IP User linuxuser ForwardAgent yes Port 22 ProxyCommand ssh user1@jump.linux.com -p 5566 nc %h %p ``` * > 權重:static NAT > DNAT > SNAT > * https://kb.juniper.net/library/CUSTOMERSERVICE/GLOBAL_JTAC/bk16110/new%20changed%20image.JPG > 其實這邊要講權重,其根本核心是轉換來源,轉換目的 能夠執行的點不同 > 譬如說,作為一臺Router. 幫你轉發封包前,我可以幫你轉換目的,但是我不能幫你轉換來源。當封包確定要轉發,知道目標是誰後,這時候不能改目的,只能改來源 > 前提是對方是基於 linux netfilter 的實作 > NAT 系列也是只有概念,但是實作標準不同 ## 43/44 | 套路篇:網絡性能優化的幾個思路(上/下)- HWChiu * 網路性能指標: - Latency: determines how fast the contents within a pipe can be transferred from the client to the server and back - Throughput - PPS - CPS: C10K問題 - TPS * 流量相關: | Performance | Tool | | -------- | -------- | | BPF/PPS | iperf3,pktgen | | -------- | -------- | | Latency | ping,hping3 | | ------- | ------- | | 連接數 | netstat,ss| * 除錯工具: | > iperf2不建議使用,使用iperf3 > 網路性能指標 - Latency - Throughput - PPS - CPS - TPS - Maximum concurrent connections * [deadman](https://github.com/upa/deadman) - MTU * [BBR](https://medium.com/kaito-blog-%E6%B5%B7%E6%96%97%E6%A8%A3-%E3%81%AE-it%E5%AE%85/google-bbr-e39e0df69e3b) * Multiplath TCP (MPTCP): Apple 的 Siri 使用 MPTCP. * [数据中心网络 BBR 不如 CUBIC ?](https://kernel.taobao.org/2019/11/bbr-vs-cubic-in-datacenter-network/?fbclid=IwAR1qAgF6LETyUUoB2egD8mgHIuuO1Yj6gCnfud_IoxlzDGJVCw6E5vsMqCo) * [系統工程師必備監控小工具 - deadman](https://blog.pichuang.com.tw/20200423-deadman/?fbclid=IwAR1g_4Th0fkszSaxWyZpi1U805frUp8T5QAXbmK8wik4hR6系統工程師必備監控小工具 - deadmanpm4Ezyb3jzbM) --- # 參考資料 # 會後問題: 1. 原本想問 SO_REUSEPORT,是不是對一般 application 比較友善 2. 想問一下iptable或是ebtable中間有一個Route Decision,他怎麼選擇要往上送localhost還是往其他chain送,這一段做了什麼magic funtion # FB [社群FB活動貼文 Round 4 #14](https://www.facebook.com/groups/sre.taiwan/permalink/1843551249144104/)