LoginSignup
7
3

★★★ openbsd を 日常使う

Last updated at Posted at 2019-05-13
1 / 22
$ date; uname -ar
Sat Oct 21 12:14:04 JST 2023
OpenBSD pro.my.domain 7.4 GENERIC.MP#1397 amd64


./comment-out.bat update.bat
export PKG_PATH=http://ftp.OpenBSD.org/pub/OpenBSD/7.4/packages/amd64/
echo 
syspatch
echo
pkg_add -u




端末を大きくするには xterm -fn 10x20 
linux のblkid 相当すのは 、 $ sysctl hw.disknames
いまswapをnvmeにおいてるが酷使されるだろうので 安いSSD(sd1)においた
swapctl -a /dev/sd1b
で linux のmkswap 相等のかんじだ
一旦起動したopenBSDから /etc/fstab のswap行をコメントアウトするだけでは /dev/sd0b (sd0はnvme)を無効にできない
しょうがないので /etc/rc.local で swapctl -d /dev/sd0b とした
そとづけUSB のopenBSDを起動し これつまり外部から sd0bのswap領域を除けないといけないだろうと思う

自分の今は
cpu-9th.jpg

OpenBSD 7.1 機動風景

0.png

##7.0はここも見て下さい
https://qiita.com/tyokai/items/8ec994845aca6b221312



ここ
https://qiita.com/kinichiro/items/a2ed08d14d2d46e28fca
にならって


cat .xsession  
                                                             
export LANG=ja_JP.UTF-8
export XMODIFIERS="@im=SCIM"
export GTK_IM_MODULE=xim
export QT_IM_MODULE=xim
scim -d
    #    # exec ck-launch-session start-lumina-desktop
exec start-lumina-desktop
    #    # exec ck-launch-session startxfce4
    #exec startxfce4
 
という風に今は xfce4から **freeBSD出身のlumina** に代えてます(なぜかxfce4でかたまりはじめましたので)

0.jpg



そして

pkg_add nano xfce mixfont-mplus-ipa scim-anthy lumina

pkg_add  xfce4-terminal roxterm  nautilus xfce4-screenshooter xfce4-mixer chromium consolekit2 xscreensaver

時間あれば xfce-extras も pkg_addされては


autologin は
/etc/X11/xenodm/xenodm-config
       DisplayManager.*.autoLogin: your_user_name

http://bluearth.cocolog-nifty.com/blog/2014/11/memolumina-desk.html より
(Linuxの)主要なウィンドウ環境はsystemdとよばれるデーモンに依存する傾向が強くなっているが、systemdはLinuxカーネルに依存しているため、Linux以外のオペレーティングシステムでは扱いにくいという一面がある。
https://news.mynavi.jp/techplus/article/20140430-a058/ より
KDEやGNOME、XFCEなどの統合デスクトップ環境はLinux向けに開発されており*BSDではこれらを移植することで使っているが、移植に時間がかかるほか、Linuxと同じクオリティを実現するのは難しい
https://wiki.archlinux.jp/index.php/Lumina より
バージョン 0.8.0+ 現在 Lumina を動かすには Qt 5, Fluxbox ウィンドウマネージャが必要であり、numlockx や xscreensaver などの様々なタスクのための X ユーティリティを多少使います

なお UEFIでは

自分は Linuxで gdiskをもちいて 前もって
 
デバイス   開始位置  終了位置    セクタ サイズ タイプ
/dev/sdb1        64   1048639   1048576   512M EFI システム
/dev/sdb4   1048640 156301424 155252785    74G OpenBSD データ
したあと インストールしてます


disklabel -E sd0
で様子をみてから

1.jpg

newfs_msdos sd0i
mount /dev/sd0i /mnt2
mkdir -p /mnt2/efi/boot
cp /mnt/usr/mdec/BOOT* /mnt2/efi/boot

なおなお auto自動でパーティションを切ってたら すでに i パーティションを作ってくれてます


##大事なシャットダウンは
https://www.youtube.com/watch?v=e1y4I-Vf4CY&feature=youtu.be

## ports

# cd /usr
# cvs -qd anoncvs@anoncvs.ca.openbsd.org:/cvs get -P ports

Any time afterwards, to update this tree:
If you are following -current:
    # cd /usr/ports
    # cvs -q up -Pd

##1a) youtube-dl(https://ytdl-org.github.io/youtube-dl/download.html)

wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
chmod a+rx /usr/local/bin/youtube-dl


ただし
 ln -s /usr/local/bin/python3 /usr/local/bin/python

##1b) NAT

下の方にも書いてます

X導入してないのですが、 マウスもキーボードもモニターもなくてもたちあがりますので 便利です
030.jpg

nat.jpg

# ifconfig                                                                                     
re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
run0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500


# ./comment-out.bat /etc/hostname.re0
inet 192.168.12.1 255.255.255.0 NONE

# ./comment-out.bat /etc/hostname.run0 
nwid Rakuten-E8F6
wpakey 00001111
dhcp



# ./comment-out.bat /etc/rc.conf.local    
xenodm_flags=
dhcpd_flags=



# ./comment-out.bat /etc/dhcpd.conf                                                            
option  domain-name "my.domain";
option  domain-name-servers 8.8.8.8;
subnet 192.168.12.0 netmask 255.255.255.0 {
        option routers 192.168.12.1;
        range 192.168.12.10 192.168.12.19;
}



cat /etc/pf.conf 
----------------
ext = "run0"
int = "re0"
table <martians> { 0.0.0.0/8 10.0.0.0/8 127.0.0.0/8 169.254.0.0/16     \
                   172.16.0.0/12 192.0.0.0/24 192.0.2.0/24 224.0.0.0/3 \
                                 198.18.0.0/15 198.51.100.0/24        \
                   203.0.113.0/24 }
  #table <spammers> persist file "/etc/spammers"
set block-policy drop
set loginterface egress
set skip on lo0
match in all scrub (no-df random-id max-mss 1440)
match out on egress inet from !(egress:network) to any nat-to (egress:0)
antispoof quick for { egress $ext $int }
block in quick on egress from <martians> to any
block return out quick on egress from any to <martians>
  #block in quick on egress from <spammers> to any
  #block return out quick on egress from any to <spammers>
block all
pass out quick inet
block in quick  on { $ext $int }  inet proto tcp from any to any port 5900
pass  in quick  on {      $int }  inet proto tcp from any to any port 22
pass  in  on { $ext $int }  inet


##1c) wifi リピーターのごときもの

1.jpg

2.jpg

1.jpg

# ./comment-out.bat /etc/rc.local  
sleep 3 ; /home/snap/wifi-router-2-wireless.bat

---

# ./comment-out.bat /home/snap/wifi-router-2-wireless.bat                  
ifconfig ural0 inet 192.168.200.1 netmask 255.255.255.0 \
media autoselect mediaopt hostap nwid oreore \
wpakey 12345678 chan 1 up
/etc/rc.d/dhcpd -f restart
pfctl -f /etc/pf.conf-wireless

---


# ./comment-out.bat /etc/dhcpd.conf                                        
option  domain-name "my.domain";
option  domain-name-servers 8.8.8.8;
subnet 192.168.200.0 netmask 255.255.255.0 {
        option routers 192.168.200.1;
        range 192.168.200.10 192.168.200.19;
}

-----

# ls -l  /etc/dhcpd.*                                                      
-rw-r--r--  1 root  wheel  200 May  7 08:19 /etc/dhcpd.conf

-----

# ./comment-out.bat /etc/pf.conf-wireless                                  
ext=run0
icmp_types = "{echoreq, unreach}"
set block-policy return
set loginterface $ext
set skip on lo0
match in all scrub (no-df max-mss 1440)
match out on $ext inet from !($ext:network) to any nat-to ($ext:0)
block log all
pass out quick
pass in quick inet proto { tcp udp gre } from any to any
pass in quick inet proto icmp all icmp-type $icmp_types keep state

---

# ./comment-out.bat /etc/hostname.run0                                     
nwid WAP
wpakey abcdefgh
dhcp


---
なお GUIは動かしてません
つまり
# ./comment-out.bat /etc/rc.conf.local                                     
dhcpd_flags=






以下は過去記事で 6.9 snapshot では未確認




NFS その 1/2

15) NFS その 2/2 
にも書いてます

openbsd <--- 192.168.188.26:arch

A)openbsd で
raid# ./comment-out.bat /etc/rc.conf.local                                             
xenodm_flags=
portmap_flags=""
mountd_flags=""
nfsd_flags="-tun 4"



# ./comment-out.bat /etc/exports                                                   
/NFS---		-maproot=bin: -network=192.168.188 -mask=255.255.255.0


# ./comment-out.bat /etc/pf.conf

                                                 
ext_if="bge0"
tcp_services="{ 22 }"  # submisson port
icmp_types="echoreq"
set block-policy return
set loginterface $ext_if
set skip on lo
set reassemble yes no-df
block in log
pass out quick
 antispoof quick for { lo  }
pass in  on  $ext_if   inet proto tcp from 192.168.188.26/32  to  ( $ext_if:0 ) 
pass in inet proto icmp all icmp-type $icmp_types



B)archで
# ./comment-out.bat nfs-2-RaidOpenBSD.bat 
mkdir -p /NFS-2-raid
umount /NFS-2-raid
mount.nfs 192.168.188.11:/NFS--- /NFS-2-raid

これにて


umount: /NFS-2-raid: not mounted.
Created symlink /run/systemd/system/remote-fs.target.wants/rpc-statd.service → /usr/lib/systemd/system/rpc-statd.service.
Filesystem             1K-blocks      Used Available Use% Mounted on
dev                      3028636         0   3028636   0% /dev
run                      3038068      9456   3028612   1% /run
/dev/sda4              279282144 157359116 107666628  60% /
tmpfs                    3038068         0   3038068   0% /dev/shm
tmpfs                       4096         0      4096   0% /sys/fs/cgroup
tmpfs                    3038072         4   3038068   1% /tmp
tmpfs                     607612        60    607552   1% /run/user/1000
192.168.188.11:/NFS--- 409062592   7592704 381016768   2% /NFS-2-raid
------
BAT  dmesg.txt

##2-b) 監視カメラmotion

# diff /etc/motion/motion.conf /etc/motion/motion.conf-o
motion.conf-ok-0625       motion.conf-ori           
ion.conf /etc/motion/motion.conf-ori                                          <
31c31
< target_dir /kansi---
---
> ; target_dir value
145c145
< webcontrol_localhost off
---
> webcontrol_localhost on


にて 他のPCから
http://192.168.12.207:8081/
にてweb cameraとなっている

もちろん root権限でmotion起動!


##3) https://www.openbsd.org/plus.html に変更箇所がのっている

##4) 時刻改善
$ date ; date -z Asia/Tokyo
Sun Apr 19 10:42:19 JST 2020
Sun Apr 19 10:42:19 JST 2020

##5) pkgのアップデート

 ./comment-out.bat pkg-u.bat                                             
export PKG_PATH=http://ftp.OpenBSD.org/pub/OpenBSD/snapshots/packages/amd64/
pkg_add -u

##6) mozcまだ来てない

elite$ cat pkg.txt | grep fcitx                                                
-rw-r--r--     11004048  2020-04-17 13:09  fcitx-4.2.9.6p2.tgz
-rw-r--r--       186672  2020-04-17 13:09  fcitx-anthy-0.2.3p0.tgz
-rw-r--r--        20184  2020-04-17 13:09  fcitx-chewing-0.2.3.tgz
-rw-r--r--        18516  2020-04-17 13:09  fcitx-gtk3-4.2.9.6p1.tgz
-rw-r--r--        29672  2020-04-17 13:09  fcitx-m17n-0.2.4.tgz
-rw-r--r--     19963160  2020-04-17 13:09  fcitx-pinyin-0.5.3.tgz
-rw-r--r--       275869  2020-04-17 13:09  fcitx-qt5-1.2.3p0.tgz
-rw-r--r--      6711107  2020-04-17 13:09  fcitx-table-0.3.8.tgz
-rw-r--r--      1442996  2020-04-17 13:16  scim-fcitx-3.1.1p8.tgz








##9 60分後 に shutdown

/sbin/shutdown -p +60 m






--------
--------

## 正規版は syspatch してね





##1) USB sound card
以下なカードで ほぼノイズ無しの音がでてくる

diff d0 d-usb-snd

213a214,219

uaudio0 at uhub2 port 4 configuration 1 interface 1 "C-Media Electronics Inc. USB Audio Device" rev 1.10/1.00 addr 5
uaudio0: class v1, full-speed, sync, channels: 2 play, 1 rec, 8 ctls
audio0 at uaudio0
uhidev2 at uhub2 port 4 configuration 1 interface 3 "C-Media Electronics Inc. USB Audio Device" rev 1.10/1.00 addr 5
uhidev2: iclass 3/0
uhid0 at uhidev2: input=4, output=4, feature=0








-------------------




##3)OpenBSDで中継
![1.jpg](https://qiita-image-store.s3.amazonaws.com/0/211097/f91da7b6-7992-bf0e-7b70-a61cf40ee956.jpeg)




|もしopenbsd で wifi ルーター をつくりたいなら|
|:---|


なかなか openbsdで動く USB wifi がないんです
ひょっと思って買った

![1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211097/ac38fe32-f107-e7d6-ea0d-66bced26e7a5.png)


でいけました
メルカリで 300円でした


全体は

スマホ --->ural0[openbsd]em0(有線)---> HUB
です


このUSB wifiがural0と認識されます

./comment-out.bat /etc/hostname.em0

dhcp

./comment-out.bat /etc/hostname.ural0

inet 192.168.12.1 netmask 255.255.255.0

./comment-out.bat /etc/rc.local
/home/open/wifi-router.bat

./comment-out.bat /home/open/wifi-router.bat
ifconfig ural0 inet 192.168.12.1 netmask 255.255.255.0
media autoselect mediaopt hostap nwid ore
wpakey 12122345 chan 1 up
/etc/rc.d/dhcpd -f restart
pfctl -f /home/open/wifi-router

lb# ./comment-out.bat /etc/sysctl.conf
net.inet.ip.forwarding=1 # 1=Permit forwarding (routing) of IPv4 packets

lb# ./comment-out.bat /etc/dhcpd.interfaces
ural0

./comment-out.bat /etc/dhcpd.conf

option domain-name "my.domain";
option domain-name-servers 8.8.8.8;
subnet 192.168.12.0 netmask 255.255.255.0 {
option routers 192.168.12.1;
range 192.168.12.10 192.168.12.19;
}

./comment-out.bat /home/open/wifi-router

ext=em0
icmp_types = "{echoreq, unreach}"
set block-policy return
set loginterface $ext
set skip on lo0
match in all scrub (no-df max-mss 1440)
match out on $ext inet from !($ext:network) to any nat-to ($ext:0)
block log all
pass out quick
pass in quick inet proto { tcp udp gre } from any to any
pass in quick inet proto icmp all icmp-type $icmp_types keep state


|現在は 有線のem0 を 無線のrun0 にして運用中です、 これはリピーターとなります。 つまり スマホ---(wifi)--->ural0:openbsd:run0----(wifi)--->[wifi router] --->internet|
|:---|





Openbsd は現状では まだいくつかのたらないところがあります

A) Linux で見られるmozcが使えないことです.
現在 Linux では fcitx-mozcが標準となってます
anthyは 古く日本語に対する変換能力が劣ります

B)音声関係です
例えば HDMI でテレビに接続しても テレビから音が出ません
USB オーディオを使うと確かに音は出ますが 自分のでは音に雑音が混入します
したがって現状では音を出すためにはサウンドカードを使う以外にはないかもしれません

C)bluetooth関係も発展途上中ではないでしょうか

でも これらを補ってもあまりある net関係の魅力に溢れてます

たとえば rsync-over-ssh.bat
rsync -avHx --delete
--exclude=".cache"
--exclude=".config"
--exclude=".local/share/Trash"
-e ssh /home/linux/ snap@192.168.0.88:/home/bsd/From-Linux/



全体像は以下で、EP-901Aはプリンターです
elecom は wifi router
AU は     有線ダケのrouter です。
![1.png](https://qiita-image-store.s3.amazonaws.com/0/211097/0b05dc7a-98f1-4d1a-c1b4-9e653e4dd4f3.png)







##4)/etc/rc.local                                          
/etc/rc.d/cupsd start



##5) **wifiです**
/etc/hostname.rum0                                     
nwid elecom2g-b4c2d9
wpakey 123abc
dhcp





##6) printerは EP-901A です。 
USB接続は超難しいので **無線接続 つまり lpd** です
これインクはボトルのを使えるのでrunning cost が安い
![1.png](https://qiita-image-store.s3.amazonaws.com/0/211097/c1f4d6d7-18cf-c65e-be6e-997f9f154ddb.png)


##7) pkg_add -u を2回ふりかけないと updateができないことありますねー

##8) chromium-71.0.3578.98 は cupsをいれてからでないとはいらなんだ



## 9) dhcpd サーバーです
ただし 今の所 イントラネット内で運用中
##  Linux PC--->em0:openbsd:run0--->wifi router->router->internet
です。

|https://www.openbsd.org/faq/pf/example1.html にあります|
|:---|
|醜いiptablesとは比べ物にならない位 pf美しい|

参考は https://www.openbsd.org/faq/faq6.html


./comment-out.bat /etc/sysctl.conf

net.inet.ip.forwarding=1 # 1=Permit forwarding (routing) of IPv4 packets

./comment-out.bat /etc/rc.conf.local

xenodm_flags=YES # on some architectures, you must also

(自分の古いノートではこの行がないとGUIがだめ)


しかも次に起動すると

./comment-out.bat /etc/rc.conf.local

dhcpd_flags=em0
xenodm_flags=YES
とdhcpd_flags=em0が 謎に加わっていた


./comment-out.bat /etc/rc.local

                       /sbin/shutdown -p +320 m

rcctl enable dhcpd
rcctl set dhcpd flags em0
/etc/rc.d/dhcpd -f start

./comment-out.bat /etc/dhcpd.interfaces

em0

./comment-out.bat /etc/dhcpd.conf

subnet 192.168.12.0 netmask 255.255.255.0 {
option domain-name-servers 8.8.8.8;
option routers 192.168.12.1;
range 192.168.12.10 192.168.12.19;
}

https://www.openbsd.org/faq/pf/example1.html
をちょっと変えた

./comment-out.bat /etc/pf.conf

int_if = "em0"
out_if = "run0"
table { 0.0.0.0/8 10.0.0.0/8 127.0.0.0/8 169.254.0.0/16
172.16.0.0/12 192.0.0.0/24 192.0.2.0/24 224.0.0.0/3
198.18.0.0/15 198.51.100.0/24
203.0.113.0/24 }
set block-policy drop
set loginterface egress
set skip on lo0
match in all scrub (no-df random-id max-mss 1440)
match out on egress inet from !(egress:network) to any nat-to (egress:0)
antispoof quick for { egress $int_if $out_if }
block in quick on egress from to any
block return out quick on egress from any to
block all
pass out quick inet
pass in on { $int_if $out_if } inet

あるいは ごく単純に
ext=run0
icmp_types = "{echoreq, unreach}"
set block-policy return
set loginterface $ext
set skip on lo0
match in all scrub (no-df max-mss 1440)
match out on $ext inet from !($ext:network) to any nat-to ($ext:0)
block log all
pass out quick
pass in quick inet proto { tcp udp gre } from any to any
pass in quick inet proto icmp all icmp-type $icmp_types keep state
でも 動きます

./comment-out.bat /etc/hostname.em0

inet 192.168.12.1 255.255.255.0 NONE

./comment-out.bat /etc/hostname.iwn0
join WirelessAP wpakey 777777
join aterm-a40bd6-a wpakey 888888
join Xiaomi_D798_5G wpakey 999999
dhcp



なお pf についてですが
Each time a packet processed by the packet filter comes in on or goes out through an interface, the filter rules are evaluated in sequential order, from first to last. 
For block and pass, the last matching rule decides what action is taken; 
if no rule matches the packet, the default action is to pass the packet without creating a state. 
For match, rules are evaluated every time they match; the pass/block state of a packet remains unchanged.




##10) minidlna


![dlna.jpeg](https://qiita-image-store.s3.amazonaws.com/0/211097/4afd0425-bf1a-4b60-673c-002453d1c191.jpeg)

./comment-out.bat /etc/minidlna.conf
port=8200
media_dir=/home/userX/share
album_art_names=Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg/AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg/Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg
enable_tivo=no
tivo_discovery=bonjour
strict_dlna=no
notify_interval=900
serial=12345678
model_number=1








## 12) nginxをWWW serverとしてつかう

/etc/nginx/nginx.conf                                                                                     

worker_processes 1;
worker_rlimit_nofile 1024;
events {
worker_connections 800;
}
http {
include mime.types;
default_type application/octet-stream;
index index.html index.htm;
keepalive_timeout 65;
server_tokens off;
server {
listen 80;
listen [::]:80;
server_name localhost; #<-for test
root /var/www/m1;
auth_basic "Restricted";
auth_basic_user_file /var/www/1/.htpasswd;
}

server {
listen 80;
listen [::]:80;
server_name h.m.jp;
root /var/www/m1;
auth_basic "Restricted";
auth_basic_user_file /var/www/1/.htpasswd;
}

server {
listen 80;
listen [::]:80;
server_name s.s.ddns.vc;
root /var/www/y2;
auth_basic "Restricted";
auth_basic_user_file /var/www/2/.htpasswd;
}

server {
listen 80;
listen [::]:80;
server_name k.s.ddns.vc;
root /var/www/k3;
auth_basic "Restricted";
auth_basic_user_file /var/www/3/.htpasswd;
}

server {
listen 80;
listen [::]:80;
server_name m.p.ddns.vc;
root /var/www/d11;
auth_basic "Restricted";
auth_basic_user_file /var/www/11/.htpasswd;
}

} 

htpasswd thinPC /var/www/1/.htpasswd

chown www /var/www/1/.htpasswd

/etc/pf.conf
ext_if="bge0"
tcp_services="{ 22, 80 }" # submisson port
icmp_types="echoreq"
set block-policy return
set loginterface $ext_if
set skip on lo
set reassemble yes no-df
block in log
pass out quick
antispoof quick for { lo }
pass in on $ext_if inet proto tcp from any to ( $ext_if:0 ) port $tcp_services
pass in inet proto icmp all icmp-type $icmp_types



##13) DVD

man によると
#growisofs -dvd-compat -Z /dev/rcd1c=image.iso
なので

growisofs -dvd-compat -Z /dev/rcd1c=$1



##14)spammer 
https://www.wizcrafts.net/chinese-blocklist.html
が元です。
spammers.txtが 以下として 

114.134.184.0/21 1.24.0.0/13 1.48.0.0/15 1.50.0.0/16 1.56.0.0/13 1.68.0.0/14 1.80.0.0/13
以下 略


これを 以下にしたら /etc/spammers が得られます。

cat spammers.txt | perl -pe 's/ /\n/g' > /etc/spammers





##15) NFS その 2/2

/etc/exports
/nfs -maproot=bin: -network=192.168.188 -mask=255.255.255.0

/etc/rc.conf.local
xenodm_flags=
portmap_flags=""
mountd_flags=""
nfsd_flags="-tun 4"


##16)DVDを視聴

  1. mount /dev/cd0c /mnt
    とDVDドライブをマウントします

2)$ mplayer -v /mnt/VIDEO_TS/VTS_11_1.VOB | grep 'audio stream'
==> Found audio stream: 128
==> Found audio stream: 129
にて 音声トラックが2つあることがわかります

3)mplayer /mnt/VIDEO_TS/VTS_11_1.VOB -aid 129 -nosub
129が日本語で 字幕なしに再生させます




---
---
---
https://ja.wikipedia.org/wiki/%E6%AD%A3%E5%8F%B2 より
正史とは一つの王朝が滅びた後、次代の王朝に仕える人々が著す。
中略
正史とはあくまで「(現)王朝が正当と認めた歴史書」という程の意味であり、
(真の)歴史事実を引き出すには歴史学の手法にのっとり厳密な史料批判を経て行う必要がある.

||
|:---|
|これは 正史は (現)支配者向きに都合よくねじ曲げられた フェイクヒストリー を示してる|


##ふろく(1) 連続足し算

tasizan.bat

add=0
while true
do
read x
echo
echo
echo
echo
echo
echo '.'
echo '-Input is---'
echo $x | printf "%'d\n" $(cat)
add=$(($add + $x))
echo
echo
echo '----------SUM is'
echo $add | printf "%'d\n" $(cat)
echo






##資料2) サンバの舞

microsoft の windows は、
openbsd , linux などのfree UNIXからの補足されないように
常に そのネットワークシステムを変化させている。
したがって sambaは それにあわせて 猫の目のようにかわらないといけない。
苦労が多いねえ

今やっと

date ; /etc/rc.d/samba start ; date

Tue May 14 02:36:22 JST 2019
smbd(ok)
nmbd(ok)
Tue May 14 02:36:48 JST 2019
と 26秒もかかるけど sambaが起動した。

testparm は

rlimit_max: increasing rlimit_max (128) to minimum Windows limit (16384)
Registered MSG_REQ_POOL_USAGE
Registered MSG_REQ_DMALLOC_MARK and LOG_CHANGED
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (128) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Loaded services file OK.
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

Global parameters

[global]
dns proxy = No
log file = /var/log/samba/smbd.%m
max log size = 50
server role = standalone server
server string = Samba Server
idmap config * : backend = tdb

[homes]
browseable = No
comment = Home Directories
read only = No

[printers]
browseable = No
comment = All Printers
path = /var/spool/samba
printable = Yes
だ。


なお
The following new rcscripts were installed: /etc/rc.d/nmbd /etc/rc.d/samba /etc/rc.d/samba_ad_dc /etc/rc.d/saslauthd /etc/rc.d/smbd /etc/rc.d/winbindd
See rcctl(8) for details.
New and changed readme(s):
/usr/local/share/doc/pkg-readmes/gamin
/usr/local/share/doc/pkg-readmes/samba




##タブレットでタッチスクリーン

vncをつかえば android タブレットが タッチパネルになる。 おー便利
![IMG_20190422_102157.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211097/6b834d20-a66d-624a-2076-f708b643246a.jpeg)

x11vnc -storepasswd
(the last one will use ~/.vnc/passwd)
x11vnc -usepw
( automatically use your ~/.vnc/passwd files)





##BIOSなthinkpad(英語キーボード)のSSDを UEFIなlifebook(日本語キーボード)に装着
おっと、 F12 でそのまま起動した
ほー、  便利

./comment-out.bat /etc/rc.local

wsconsctl keyboard.encoding=jp


しないと英語キ-ボードのままになる


##画像などについては 次を見てください
https://openbsd-akita.blogspot.com/2020/03/openbsd.html


##音量調節は
pavucontrol ですね

## clamav


./comment-out.bat virus-scan.bat
freshclam
mkdir -p /Virus
clamscan --recursive /home/book --move=/Virus
echo ''
echo ''
echo '----result--------'
ls -ltr /Virus
echo '----result--------'
echo ''
echo ''

./comment-out.bat /etc/freshclam.conf
DatabaseMirror database.clamav.net

life$ ./comment-out.bat /etc/clamd.conf
LogFile /var/log/clamd.log
LogFileMaxSize 2M
LogRotate yes
LocalSocket /tmp/clamd.socket
User _clamav
MaxRecursion 12



---------------
garuda linux では以下です




❯ ./comment-out.bat /etc/clamav/freshclam.conf
UpdateLogFile /var/log/clamav/freshclam.log
PidFile /run/clamav/freshclam.pid
DatabaseMirror database.clamav.net
NotifyClamd /etc/clamav/clamd.conf

❯ ./comment-out.bat /etc/clamav/clamd.conf
LogFile /var/log/clamav/clamd.log
LogTime yes
PidFile /run/clamav/clamd.pid
TemporaryDirectory /tmp
LocalSocket /run/clamav/clamd.ctl
User clamav




## スパム対策 というか 楽天でテザリングして 節約を図る準備体操


![1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211097/04f7f512-d60f-6abb-612a-f32639686cdb.png)

USBテザリングなので openbsdでは 楽天ミニとの接続が **urndis0** にご注意下さい


curl -O http://nami.jp/ipv4bycc/cidr.txt.gz && gunzip -f cidr.txt.gz

grep -e CC -e HH -e KK cidr.txt > s0
で危ない国を選び

sed -E 's/[CC|HH|KK]//g' s0 > s1

awk '{sub(/^[ \t]+/, ""); print}' s1 > s2
で 行頭の空白をのけ

cp s2 /etc/spammers

こうして
$ head /etc/spammers
1.0.1.0/24
1.0.2.0/23
1.0.32.0/19
になっている

./comment-out.bat /etc/pf.conf

ext = "urndis0"
int = "em0"
table { 0.0.0.0/8 10.0.0.0/8 127.0.0.0/8 169.254.0.0/16
172.16.0.0/12 192.0.0.0/24 192.0.2.0/24 224.0.0.0/3
192.168.0.0/16 198.18.0.0/15 198.51.100.0/24
203.0.113.0/24 }
table persist file "/etc/spammers"
set block-policy drop
set loginterface egress
set skip on lo0
match in all scrub (no-df random-id max-mss 1440)
match out on egress inet from !(egress:network) to any nat-to (egress:0)
antispoof quick for { egress $ext $int }
block in quick on egress from to any
block return out quick on egress from any to
block in quick on egress from to any
block return out quick on egress from any to
block all
pass out quick inet
block in quick on { $ext $int } inet proto tcp from any to any port 5900
pass in quick on { $int } inet proto tcp from any to any port 22

とすると

pfctl -sr

match in all scrub (no-df random-id max-mss 1440)
match out on egress inet from ! (egress:network) to any nat-to (egress:0) round-robin
block drop in quick on ! egress inet from 192.168.42.0/24 to any
block drop in quick inet from 192.168.42.218 to any
block drop in quick on ! urndis0 inet from 192.168.42.0/24 to any
block drop in quick on ! em0 inet from 192.168.12.0/24 to any
block drop in quick inet from 192.168.12.1 to any
block drop in quick on urndis0 inet6 from fe80::49d:c5ff:fe46:4453 to any
block drop in quick on egress from to any
block return out quick on egress from any to
block drop in quick on egress from to any
block return out quick on egress from any to
block drop all
pass out quick inet all flags S/SA
block drop in quick on urndis0 inet proto tcp from any to any port = 5900
block drop in quick on em0 inet proto tcp from any to any port = 5900
pass in quick on em0 inet proto tcp from any to any port = 22 flags S/SA
pass in on urndis0 inet all flags S/SA
pass in on em0 inet all flags S/SA

となってます

##ただし 楽天ミニをLTEで使う場合です


![スクリーンショット_2020-12-09_13-36-29.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211097/2a788f02-b28c-bb2c-ee82-9be727bd8bf8.png)


##楽天ミニをwifi ルーターに接続の時は

./comment-out.bat USB-thether-wifi.bat
pfctl -f /etc/pf.conf-ok-USBtether-wifi
sh /etc/netstart
echo
echo
echo
ping -c 1 www.youtube.com
echo '-------------'
echo
echo
ifconfig | egrep 192 |grep -v "12"
echo '-------------'
echo
echo

PC--有線LAN---192.168.12.1:openbsd----USB---rakutenMINI----wifiROUTER
なので

./comment-out.bat /etc/pf.conf-ok-USBtether-wifi

ext = "urndis0"
int = "em0"
table { 0.0.0.0/8 10.0.0.0/8 127.0.0.0/8 169.254.0.0/16
172.16.0.0/12 192.0.0.0/24 192.0.2.0/24 224.0.0.0/3
192.168.12.0/24 198.18.0.0/15 198.51.100.0/24
203.0.113.0/24 }
192.168.1.0/24 192.168.10.0/24 192.168.12.0/24 192.168.42.0/24 198.18.0.0/15 198.51.100.0/24
table persist file "/etc/spammers"
set block-policy drop
set loginterface egress
set skip on lo0
match in all scrub (no-df random-id max-mss 1440)
match out on egress inet from !(egress:network) to any nat-to (egress:0)
antispoof quick for { egress $ext $int }
block in quick on egress from to any
block return out quick on egress from any to
block in quick on egress from to any
block return out quick on egress from any to
block all
pass out quick inet
block in quick on { $ext $int } inet proto tcp from any to any port 5900
pass in quick on { $int } inet proto tcp from any to any port 22
pass in on { $ext $int } inet


./comment-out.bat arp-scan.bat

arp-scan -I run0 -l

snap# ./arp-scan.bat
Interface: run0, datalink type: EN10MB (Ethernet (10Mb))
Starting arp-scan 1.9 with 256 hosts (http://www.nta-monitor.com/tools/arp-scan/)
192.168.0.1 e8:f6 (Unknown)
192.168.0.100 9a:8d Raspberry Pi Foundation
192.168.0.101 65:a4 Shenzhen Century Xinyang Technology Co., Ltd
192.168.0.106 74:cc Shenzhen Century Xinyang Technology Co., Ltd
192.168.0.108 f0:d8 Intel Corporate
531 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.9: 256 hosts scanned in 2.704 seconds (94.67 hosts/sec). 5 responded




![1.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211097/1a86dec6-4216-4501-4e16-e9813a43983a.jpeg)






---------
---------
## USB camera です
---------
https://www.openbsd.org/faq/faq13.html
より

# diff /etc/sysctl.conf /etc/sysctl.conf-ori  
41d40
< kern.video.record=1

---------


dmesg | grep Corp

uhidev0 at uhub3 port 4 configuration 1 interface 0 "Lite-On Technology Corp. HP Wireless Slim Keyboard - Skylab JP" rev 2.00/0.69 addr 4
uhidev1 at uhub3 port 4 configuration 1 interface 1 "Lite-On Technology Corp. HP Wireless Slim Keyboard - Skylab JP" rev 2.00/0.69 addr 4
uhidev2 at uhub3 port 4 configuration 1 interface 2 "Lite-On Technology Corp. HP Wireless Slim Keyboard - Skylab JP" rev 2.00/0.69 addr 4
uvideo0 at uhub2 port 1 configuration 1 interface 0 "Vimicro Corp. Venus USB2.0 Camera" rev 2.00/1.00 addr 3
uvideo0 at uhub2 port 1 configuration 1 interface 0 "Vimicro Corp. Venus USB2.0 Camera" rev 2.00/1.00 addr 3
uvideo0 at uhub2 port 1 configuration 1 interface 0 "Vimicro Corp. Venus USB2.0 Camera" rev 2.00/1.00 addr 3
uvideo0 at uhub2 port 1 configuration 1 interface 0 "Vimicro Corp. Venus USB2.0 Camera" rev 2.00/1.00 addr 3

kansi.bat

while true
do
x=date +%M:%S
y=date +%Y%m%d
z=date +%H
/usr/local/bin/fswebcam -r 384x288 -S 2 /home/open/kansi---/$x.jpg
mkdir -p /home/open/kansi---/$y
mkdir -p /home/open/kansi---/$y/$z
mv /home/open/kansi---/$x.jpg /home/open/kansi---/$y/$z/
sleep 10
done

./comment-out.bat fswebcam-clear.bat


x=date +%Y%m%d
z7=date -r $(expr $(date +%s) - 604800) +%Y%m%d
z6=date -r $(expr $(date +%s) - 518400) +%Y%m%d
z5=date -r $(expr $(date +%s) - 432000) +%Y%m%d
z4=date -r $(expr $(date +%s) - 345600) +%Y%m%d
echo $z7
echo $z6
echo $z5
echo $z4
rm -rf /home/open/kansi---/$z7
rm -rf /home/open/kansi---/$z6
rm -rf /home/open/kansi---/$z5
rm -rf /home/open/kansi---/$z4


./comment-out.bat /etc/rc.local

/home/open/kansi.bat

crontab -l | ./comment-out.bat -

SHELL=/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin
HOME=/var/log
0 * * * * /usr/bin/newsyslog
30 1 * * * /bin/sh /etc/daily
30 3 * * 6 /bin/sh /etc/weekly
30 5 1 * * /bin/sh /etc/monthly
0 * * * * /home/open/fswebcam-clear.bat



あとは openbsd と manjaloに rsyncをいれ
manjaroで


rsync -avHx --delete -e ssh open@192.168.10.107:/home/open/kansi---/    /home/nec/KANSI---/ 
で manjaroに 画像を持ってきて確認をする


-----
-----
-----


|2022年3月 追記 (またもや nat マシン)|
|:---|



![1.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211097/f806ce0f-f15f-0a39-cdd9-ce5a696dede4.jpeg)




./comment-out.bat /etc/sysctl.conf

net.inet.ip.forwarding=1 # 1=Permit forwarding (routing) of IPv4 packets

./comment-out.bat /etc/dhcpd.conf

option domain-name "my.domain";
option domain-name-servers 8.8.8.8;
subnet 192.168.12.0 netmask 255.255.255.0 {
option routers 192.168.12.1;
range 192.168.12.10 192.168.12.19;
}

./comment-out.bat /etc/rc.local

/home/bsd/nat.bat

./comment-out.bat /etc/pf.conf

ext = "em0"
int = "axe0"
table { 0.0.0.0/8 10.0.0.0/8 127.0.0.0/8 169.254.0.0/16
172.16.0.0/12 192.0.0.0/24 192.0.2.0/24 224.0.0.0/3
198.18.0.0/15 198.51.100.0/24
203.0.113.0/24 }
set block-policy drop
set loginterface egress
set skip on lo0
match in all scrub (no-df random-id max-mss 1440)
match out on egress inet from !(egress:network) to any nat-to (egress:0)
antispoof quick for { egress $ext $int }
block in quick on egress from to any
block return out quick on egress from any to
block all
pass out quick inet
block in quick on { $ext $int } inet proto tcp from any to any port 5900
pass in quick on { $int } inet proto tcp from any to any port 22
pass in on { $ext $int } inet

./comment-out.bat nat.bat

ifconfig axe0 192.168.12.1
/etc/rc.d/dhcpd -f restart



![スクリーンショット_2022-03-11_04-10-31.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211097/24a0156c-82a0-00c2-ffe2-b3c80cdf85c1.png)


音は usb sound card です

n# dmesg | grep USB
acpi0: wakeup devices PE0_(S4) PE1_(S4) PE3_(S4) PE5_(S4) PE6_(S4) PEX1(S4) PEX5(S4) PEX6(S4) PEX7(S4) PEX8(S4) USB1(S1) USB2(S1) USB3(S1) USB4(S1) USB5(S1) USB6(S1) [...]
ehci0 at pci2 dev 26 function 0 "Intel 3400 USB" rev 0x05: apic 1 int 21
usb0 at ehci0: USB revision 2.0
ehci1 at pci2 dev 29 function 0 "Intel 3400 USB" rev 0x05: apic 1 int 20
usb1 at ehci1: USB revision 2.0
uaudio0 at uhub2 port 2 configuration 1 interface 1 "GeneralPlus USB Audio Device" rev 1.10/1.00 addr 3
uhidev0 at uhub2 port 2 configuration 1 interface 3 "GeneralPlus USB Audio Device" rev 1.10/1.00 addr 3
uhidev3 at uhub3 port 6 configuration 1 interface 0 "Dell Dell USB Keyboard" rev 1.10/3.52 addr 5





##  X-1) HPノートへのインストール(ryzen + GPU)

https://openbsd-akita.blogspot.com/2022/03/ryzen3-gpuradeon.html

## X-2) 仮想モニターで vnc over ssh

https://openbsd-akita.blogspot.com/2022/03/vncover-ssh.html


## X-2) linux を利用して SSDをnvmeへクローニング

https://openbsd-akita.blogspot.com/2022/04/linux-ssdnvme.html


##X-3) 7.1 snapshots httpd(誤りあるかもなので !!! 鵜呑みにしないでください !!!)

https://www.youtube.com/watch?v=TnmiJjEp3z8&t=11s
を参考にしましたが 受け入れてない部分も多々です


cat /etc/httpd.conf

$OpenBSD: httpd.conf,v 1.22 2020/11/04 10:34:18 denis Exp $

server "default" {
listen on * port 80
root "/acme"
}

ls -l /var/www/acme/index.html

-rw-r--r-- 1 root daemon 37 Apr 13 06:38 /var/www/acme/index.html

rcctl -f restart httpd

httpd(ok)
httpd(ok)

しかし https ではアクセス無理です。 
http://localhost
で確認はしました


この延長で印刷は
https://openbsd-akita.blogspot.com/2022/04/windows-11.html
をご覧ください。 なんとかUTF8問題を顕在化しないようにしてます


## X-4) google document 音声入力

https://www.openbsd.org/faq/faq13.html にならって

Enabling Audio Recording
For privacy reasons, audio recording is disabled by default in OpenBSD. The kern.audio.record sysctl may be used to enable it.

sysctl kern.audio.record=1

echo kern.audio.record=1 >> /etc/sysctl.conf

して
pulseau0とすると

![Photo Marker_20220517_115358.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211097/d4546f7c-e109-5566-3f4d-d54fc53539df.jpeg)



## X-5)ntpd

http://fuguita.org/index.php?cmd=read&page=%B2%CF%C6%DA%C8%C4%A5%AC%A5%A4%A5%C9
かたのいわれるとおり
【メモ】⇒ntpdは時刻のずれを非常にゆっくりと修正していきます。
でした。 

$ ./comment-out.bat /etc/ntpd.conf
servers pool.ntp.org
server time.cloudflare.com
sensor *
constraint from "9.9.9.9" # quad9 v4 without DNS
constraint from "2620:fe::fe" # quad9 v6 without DNS
constraints from "www.google.com" # intentionally not 8.8.8.8

$ ntpctl -s status
5/5 peers valid, constraint offset -2s, clock synced, stratum 4


自分は2時間ほどかかりました

## X-6) burn iso
growisofs -dvd-compat -Z /dev/rcd0c=manjaro-xfce-21.3.0-220617-linux515.iso


## X-7) nvmeを 128Gから 256GBへ置換
nvmeには 2022/7/13 時点では growfs が通用しません

そのため 256GBnvme に OpenBSDを
同じ デバイス名 、 同じ ユーザー名 でいれたあと
rsync -avHx 128G 256GB な感じでします

## 一つだけ  256GBの /etc/fstab を 
sysctl hw.disknames  を参考にして 書き換えねばなりませんでした



## X-8) HPの drivelock 問題
dd 済みの img(500GB機械式ハードディスクにある) から 
「windows 11が 既にはいっているnvme」 に ddで書き戻そうとし
USBメモリにあるopenbsdの起動が drivelockで ダメでした(中古だったのでパスワードしらないため)

でも 新品のpatriot の nvme に書き戻せました
これにて以下の9の表示のPCの オンボードのnvmeスロットが使えました

![1.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/211097/2b7262fc-5f58-186d-a912-263fd0ceb491.jpeg)






## X-9) CPU温度
$ ./comment-out.bat /etc/rc.conf.local                                     
xenodm_flags=
sensorsd_flags=


$ ./comment-out.bat temp.sh                                                
while true
do
date +%H:%M
sysctl hw.sensors.cpu0.temp0
y
done

なお
$ sysctl hw
でいろんな情報あります



## X-10)
7
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
3