海运的博客

OpenWrt/PandoraBox多网段转发udp广播包

发布时间:April 1, 2022 // 分类: // No Comments

之前有写不同网段间转发mdns消息,对于依赖udp广播的程序可通过iptables tee镜像流量转发广播到不同网段。
安装tee模块:

opkg install iptables-mod-tee
#将10.0.0.0网段udp广播目标端口9687转发到10.0.1.0网段
iptables -t mangle -I INPUT -i br-lan -d 255.255.255.255 -p udp --dport 9687 -m ttl --ttl-gt 0 -j TTL --ttl-set 1
iptables -t mangle -I INPUT -i br-lan -d 255.255.255.255 -p udp --dport 9687 -m ttl --ttl-gt 0 -j TEE --gateway 10.0.1.255

#反向
iptables -t mangle -I INPUT -i br-robot -d 255.255.255.255 -p udp --dport 9687 -m ttl --ttl-gt 0 -j TTL --ttl-set 1
iptables -t mangle -I INPUT -i br-robot -d 255.255.255.255 -p udp --dport 9687 -m ttl --ttl-gt 0 -j TEE --gateway 10.0.0.255

iptables放行9687数据包:

iptables -A FORWARD -i br-robot -o br-lan -p udp --dport 9687 -j ACCEPT

不支持iptables tee模块可使用独立的udp广播转发程序:
https://github.com/nomeata/udp-broadcast-relay
参考:
https://odi.ch/weblog/posting.php?posting=731

rclone加密备份目录文件

发布时间:March 19, 2022 // 分类: // No Comments

配置文件:

[local]
type = local

[crypt]
type = crypt
remote = local:/dev/shm/crypt/
filename_encryption = Off
directory_name_encryption = false
password = HFE1_2h03c4-rN0JHo4qcdCnhwsI0u5LFdCWewohDx2Q8ZIDnbY
password2 = irHYz49lLfqNwreRAFiC_FD2P4f9gpLWfh0F89JgyToGUiyxDvM

https://rclone.org/crypt/

rsync/rclone对比目录及同步

发布时间:March 19, 2022 // 分类: // No Comments

rsync使用参数:

-v #详细输出
-i #显示差异
-n/--dry-run #仅测试,配合-i对比目录差异
-a #相当于-rlptgoD,-D相当于--devices和--specials
-r #递归目录
-l #链接文件
-p #同步文件权限
-t #同步修改时间
-g #同步所有者
-o #同步用户组
--devices #同步设备文件
--specials #同步特殊文件,如socket
--delete #删除目标目录在源目录不存在的文件,相当于mirror。
--progress #显示进度和速度
--ignore-existing #不同步目标已存在的文件
--preallocate #预先分配空间,减少碎片
-c #通过文件校验判断差异,默认使用文件大小和修改时间判断差异

对比目录差异:

rsync -n -a -i -v src/ dst/

仅使用文件大小对比差异:

rsync -n -r -i -v --size-only src/ dst/

rsync显示差异格式解读:
https://stackoverflow.com/questions/4493525/what-does-f-mean-in-rsync-logs
https://stackoverflow.com/questions/1113948/rsync-output
https://download.samba.org/pub/rsync/rsync.1

使用rclone同步及比较目录差异:

#默认使用时间和大小对比
rclone sync --dry-run src/ dst/ 
--checksum #使用文件hash对比
#默认使用文件大小和hash对比
rclone check src/ dst/
--size-only #仅使用文件大小对比

https://forum.rclone.org/t/how-to-utilize-mod-time-and-size-instead-checksums-during-sync-and-check/14020/10

samba/smb文件共享显示短文件名

发布时间:March 12, 2022 // 分类: // No Comments

当samba遇到windows上不能作为文件名的字符时会将文件名转换为8.3 format,可以禁用文件名转换并将不合适的字符转换为windows可用的文件名。

#可查看ASCII码表hex值
catia:mappings = 0x22:0xa8,0x2a:0xa4,0x2f:0xf8,0x3a:0xf7,0x3c:0xab,0x3e:0xbb,0x3f:0xbf,0x5c:0xff,0x7c:0xa6
mangled names = no
vfs objects = catia

参考:
https://www.oreilly.com/openbook/samba/book/ch05_04.html
https://unix.stackexchange.com/questions/299130/samba-how-to-display-files-with-colon-in-their-names
https://www.samba.org/samba/docs/current/man-html/vfs_catia.8.html
https://lwp.interglacial.com/appf_01.htm

OpenWrt/PandoraBox多网段中继转发mDNS Reflector

发布时间:February 12, 2022 // 分类: // No Comments

为了安全将物联网设备单独使用一个网段和本地网络隔离,这样基于mdns协议的发现应用就不能使用了,如电视投屏、打印机等,可以使用mDNS Reflector来中继两个网段的mdns。
编译方法参考:k2p交叉编译smartdns/openssl

/usr/local/bin/mdns-reflector -n br-lan br-robot br-guest

路由配置iptables防火墙允许udp 5353入,并允许本地网络访问电视所在的网络:

iptables -A INPUT -i br-robot -p udp --dport 5353 -j ACCEPT
iptables -A FORWARD -i br-lan -j ACCEPT
iptables -A FORWARD -i robot -o br-lan -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
分类
最新文章
最近回复
  • 海运: 可能版本问题
  • 海运: 如果运营商限制型号
  • 海运: 没有
  • Mruru: 烽火猫切换rootfs的方法有么大佬?
  • nono: 修改光猫型号是做啥子用的
  • 960: root账号默认密码hg2x0 不对哇
  • rer: 感谢分享!~
  • opnfense: 谢谢博主!!!解决问题了!!!我之前一直以为内置的odhcp6就是唯一管理ipv6的方式
  • liyk: 这个方法获取的IPv6大概20分钟之后就会失效,默认路由先消失,然后Global IPV6再消失
  • 海运: 不好意思,没有。
归档