202308¶
vyos upgrade¶
[edit]
vyos@vyos# run add system image https://s3-us.vyos.io/rolling/current/vyos-rolling-latest.iso
Unable to fetch digital signature file.
Do you want to continue without signature check? (yes/no) [yes] yes
Checking MD5 checksums of files on the ISO image...OK.
Done!
What would you like to name this image? [1.4-rolling-202308020317]:
OK. This image will be named: 1.4-rolling-202308020317
Installing "1.4-rolling-202308020317" image.
Copying new release files...
Would you like to save the current configuration
directory and config file? (Yes/No) [Yes]:
Copying current configuration...
Would you like to save the SSH host keys from your
current configuration? (Yes/No) [Yes]:
Copying SSH keys...
Running post-install script...
Setting up grub configuration...
Done.
[edit]
vyos@vyos# run show system i
The system currently has the following image(s) installed:
1: 1.4-rolling-202308020317 (default boot)
2: 1.2.8- (running image)
3: 1.1.8
[edit]
vyos@vyos# save
Saving configuration to '/config/config.boot'...
Done
[edit]
vyos@vyos# run reboot
Are you sure you want to reboot this system? [y/N] y
volatileの使い所¶
- "volatileの使い方① - 組み込みC/C++"
- "volatileの使い方② - 組み込みC/C++"
- 通常の処理と割り込み関数の両方から使う変数はvolatileで修飾したほうが良い
- 最適化によって条件分岐の評価が省略されたり,メモリへの展開等が省略される可能性がある.
- あるスコープの外で変化しうる変数を扱う際にはvolatileをつけておくほうが良さそう.
- ペリフェラルのレジスタへの参照など.
sshでnegotiate error¶
- error
Unable to negotiate with x.x.x.x port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss
Unable to negotiate with x.x.x.x port 22: no matching cipher found. Their offer: aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc
- ssh optionでoverrideしたりする(ex.
ssh -oHostKeyAlgorithms +ssh-rsa
)KexAlgorithms +diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
HostKeyAlgorithms +ssh-rsa
Ciphers +aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc
Solid state ミュート回路¶
% ln -s ~/<path_to>/HyperlinkHelper ~/Library/Application\ Support/Sublime\ Text/Packages/
¶
containerでiperf¶
pm run -it --rm -p 5201:5201 networkstatic/iperf3 -s
pm run -it --rm networkstatic/iperf3 -c 127.0.0.1 -t 30
- iperfのtips
- udpモードだとdropなしに最大帯域を探るのは難易度が高い.一般的にtcpモードで良いと考えられる.
- tcp mode:
iperf3 -c x.x.x.x -t 30 --get-server-output
- udpモードで測定するケース
- 単に負荷がかかればいいケース
- ジッタ測定をしたいケース
- 片方向通信のみしか許可されていないなどの特殊環境下にある場合(iperf2)
- udp mode:
iperf3 -c x.x.x.x -t 30 --get-server-output -u -b 10M
- tcp mode:
- 特に遅延が大きい環境等で,本来の最大帯域をudpモードを利用せずに測定するにはtcpモードにおいてwindowサイズを調整した測定を行うとよい.
- tcp window size option:
-w 60K
- tcp window size option:
- udpモードだとdropなしに最大帯域を探るのは難易度が高い.一般的にtcpモードで良いと考えられる.
- ref: iperf での帯域測定検証(tcpモード vs udpモードなど) - Qiita
DNS performance test¶
- GitHub - DNSPerf/dnsperf: DNS Performance testing tool
- DNS Performance - Compare the speed and uptime of enterprise and commercial DNS services | DNSPerf
dnsperf -s x.x.x.x -d query.txt
- ISC Open Source Projects / queryperf · GitLab
queryperf -s x.x.x.x -d query.txt
HTTPでs3¶
Authorization headerとしてaccsess key, secret key, bucket, key, date, content-typeから計算される値の付与が必要
- たとえばpythonだと下記.
import base64 import hmac from hashlib import sha1 access_key = 'xxxxx'.encode("UTF-8") secret_key = 'yyyyy'.encode("UTF-8") bucket='test_bucket' key='test.txt' date='Fri, 21 Apr 2023 15:28:00 GMT' content_type="application/octet-stream" # StringToSign = {HTTP-Verb} + "\n" + # {Content-MD5} + "\n" + # GETでは省略可 # {Content-Type} + "\n" + # GETでは省略可 # {Date} + "\n" + # {CanonicalizedAmzHeaders} + # {CanonicalizedResource}; # GETでは省略可 string_to_sign = f'GET\n\n{content_type}\n{date}\n/{bucket}/{key}'.encode("UTF-8") signature = base64.b64encode(hmac.new(secret_key, string_to_sign, sha1).digest()).strip() authorization_header=f"AWS {access_key.decode()}:{signature.decode()}"
curl --request POST 'https://example.com/{bucket}/{key}' \ --header 'Host: example.com' \ --header 'Date: {date}' \ --header 'Content-Type: application/octet-stream' \ --header 'Authorization: {authorization_header}' \ --data-raw '{data}'
date, content-typeはhttp headerの値と同値にしておく必要がある.
- 特にdateは大きく乖離している場合に認証が通らない.基本同一とすることが望ましい.
References
iptablesでicmp floodを切る¶
- ddos対策とかに.
- 前提
- echo reply
- ipv4: 0
- ipv6: 129
- echo request
- ipv4:8
- ipv6: 128
- type ref:
iptables -p icmp -h
ip6tables -p ipv6-icmp -h
- echo reply
- limitで単純に制限をかける
iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s --limit-burst 5 -j ACCEPT
ip6tables -A INPUT -p ipv6-icmp --icmpv6-type echo-request -m limit --limit 1/s --limit-burst 5 -j ACCEPT
単純なlimitだと着弾したもの全てに対するカウントになってしまう.この場合,不正な通信により正常な通信も落とされる恐れがある. source ip別等でquotaを持ちたい場合はhashlimitを用いると可能.
iptables -A INPUT -p icmp --icmp-type 8 \
-m conntrack --ctstate NEW,RELATED,ESTABLISHED -m hashlimit --hashlimit-name PING --hashlimit 15/sec --hashlimit-burst 5 --hashlimit-mode srcip --hashlimit-htable-expire 300000 -j ACCEPT
ip6tables -A INPUT -p ipv6-icmp --icmpv6-type 128 \
-m conntrack --ctstate NEW,RELATED,ESTABLISHED -m hashlimit --hashlimit-name PING6 --hashlimit 15/sec --hashlimit-burst 5 --hashlimit-mode srcip --hashlimit-htable-expire 300000 -j ACCEPT
# hashtableを確認できる
cat /proc/net/ipt_hashlimit/PING
cat /proc/net/ipt_hashlimit/PING6
$ iptables -p icmp -m hashlimit -h
...snip...
--hashlimit-upto <avg> max average match rate
[Packets per second unless followed by
/sec /minute /hour /day postfixes]
--hashlimit-above <avg> min average match rate
--hashlimit-mode <mode> mode is a comma-separated list of
dstip,srcip,dstport,srcport (or none)
--hashlimit-srcmask <length> source address grouping prefix length
--hashlimit-dstmask <length> destination address grouping prefix length
--hashlimit-name <name> name for /proc/net/ipt_hashlimit
--hashlimit-burst <num> number to match in a burst, default 5
--hashlimit-htable-size <num> number of hashtable buckets
--hashlimit-htable-max <num> number of hashtable entries
--hashlimit-htable-gcinterval interval between garbage collection runs
--hashlimit-htable-expire after which time are idle entries expired?
- uptoとaboveは逆の働きをするので,ACCEPTとDROPで使い分けができる.
- burstは理解が難しいが,下記のようなケースで活用できる
- 感覚的にはダイナミクスでいうゲートのような感覚.burst閾値を超えるとrate limitが初めて発動する.
512kb/s
を超過するとマッチするが、1mb
に達するまではマッチせず許可する--hashlimit-above 512kb/s --hashlimit-burst 1mb
- ref: iptables アクセス回数を制限する - セキュリティ
- ref: Understanding iptable’s hashlimit module | Poorly Documented
下駄,雪駄,草履の違い¶
- 下駄
- 木からなる台に穴が3つ空いていて、そこに花緒をすげられるもの
- 桐でできているもの
- 草履
- 草履の方が広い意味であり、雪駄は草履の一種
- コルク材に革や布などを巻き、重ね、底・天を整形した履物
- 下駄よりも格式が高い
- 男女ともに用いる
- 雪駄
- 畳表の裏には革が縫い付けられている
- 踵には金具がついていて、歩くとチャリチャリと存在感のある音が鳴る
- かつては男性の履物
- ref: 下駄と雪駄と草履の違い~目利きポイント~ ―下駄コラム―丸屋履物店
ttyを強制切断する¶
root@xxx# w
02:22:11 up 44 min, 2 users, load average: 1.12, 1.08, 1.01
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
jp7fkf pts/0 x.x.x.x 01:42 2:19 2.47s 0.34s ssh x.x.x.x
jp7fkf pts/1 x.x.x.x 02:20 0.00s 1.28s 0.19s sshd: jp7fkf
root@xxx# ps -lt pts/0
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
4 S 1000 10038 10035 1 80 0 - 1109 wait pts/0 00:00:00 vbash
4 S 0 10050 10038 0 80 0 - 1440 poll_s pts/0 00:00:00 sudo
4 S 0 10054 10050 0 80 0 - 1330 wait pts/0 00:00:00 su
4 S 0 10059 10054 4 80 0 - 1255 wait pts/0 00:00:00 bash
0 R 0 10065 10059 0 80 0 - 1486 - pts/0 00:00:00 ps
root@xxx# kill 10038