-
Notifications
You must be signed in to change notification settings - Fork 8.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add freebsd support #2246
add freebsd support #2246
Conversation
- transparent proxy (pf rdr) in IPv4 environment - support both tcp and udp - enable TCP_FASTOPEN, SO_REUSEPORT_LB, SO_REUSEADDR - sockopt:mark is mapped to SO_USER_COOKIE
@lucifer9 |
@ToutyRater 是的。尽量用比较新的 FreeBSD 版本,使用 pf 来做防火墙规则就行,透明代理需要 root 权限。IPv4 环境我自用近半个月了。 |
谢谢,我之前查了好多关于 BSD 透明代理的资料,最终都无奈放弃。目前在用着 Linux,过段时间再研究 FreeBSD 的。 |
@ToutyRater 不同操作系统,不同防火墙下,获取目标地址的方式不一样。FreeBSD+pf 的组合我刚测试了下是正常的。Linux 下只需要一个小改动就行了。#2281 |
我看新版本增加了freebsd的透明代理支持,测试有一下遇到一些问题。不知道是自己配置有问题,还是程序有bug,所有请哪位大神关注一下; 环境是pfsense2.4.4-p3,这个freebsd版本是11; 网关出口的nat规则如下: 网关上的v2ray取错了目标地址,以任意门的监听端口作为远程服务器的端口,所以报错如下:
客户端的配置文件如下:
|
哦霍?mac os pf同样适用? |
在hyper-v虚拟环境下测试没能复现。可否贴一下你的pfsense网络环境呢,我这边没做网桥和vlan(pfsense默认),也许有这方面原因。我是用的tcp 53端口做的测试,dig a www.baidu.com @8.8.8.8 +tcp,config.json 用的你上面给出的。 [2.4.4-RELEASE][[email protected]]/root: ./v2ray -config config.json |
Mac 不行,因为Mac下的pf跟freebsd上面的pf比起来,一些内部的数据结构不同。当然改起来也不太麻烦。不过话又说回来,真的有必要用Mac来做透明代理么... 😃 |
好玩呗 - - |
@fbion 如果只有一台电脑,透明代理代理自己还不如用v2ray+proxifier。如果好几台Mac,随便某个开个代理服务也方便过透明代理。除非是局域网内有Windows或者Linux命令行这种,透明代理才会比较方便。不过这种时候我宁愿开虚拟机做透明代理了。macOS 改一下 pfioc_natlook 的定义和相关读写的部分就行了。有可能有些系统常量定义不一样。苹果自己的开源站点也都能查到。 |
@lucifer9 是的 proxifier蛮好用 |
感谢您的回复,我更新到了git上的最新的版本;目前遇到的情况是这样的,tcp可以通;upd遇到问题;upd发出去的包可以到达目标服务器,但是回不来; 环境pfsen2.4.4-p3
dns查询
返回日志
配置文件
补充: |
@magicst0ne Sorry,FreeBSD 11 没有 SO_REUSEPORT_LB 的支持,我之前没注意到这个所以代码只能在FreeBSD 12和以后的版本跑。#2366 加上了SO_REUSEPORT来支持FreeBSD 11以及基于它的pfsense,实测通过。 |
@lucifer9 can you document on how to setup freebsd pf rules for transparent proxy? Googled around, no useful information |
Sure. I use the following rules when testing: int_if = "hn0" rdr pass on $int_if proto { tcp, udp } from any to ! -> 127.0.0.1 port v2ray_dokodemo_port If you also want to redirect the traffic of your FreeBSD box, you may add the following: rdr pass on lo0 proto { tcp,udp } from $ext_if to ! -> 127.0.0.1 port v2ray_dokodemo_port |
@lucifer9 thanks, you defined a table (with no name) but it was not used anywhere in your example. |
Sorry, Github Editor ate the character.
|
@lucifer9 这对略懂CLI的人来说太难了,没看懂。 可否写一篇blog介绍一下如何在pfSense上设置?
但我不懂得怎么配置,,,,,以及unbound要不要改动什么。。 BTW, 貌似pfSense Firewall alias 及 pfBlockerNG 都不支持 |
transparent proxy (pf rdr) in IPv4 environment
support both tcp and udp
enable TCP_FASTOPEN, SO_REUSEPORT_LB, SO_REUSEADDR
sockopt:mark is mapped to SO_USER_COOKIE