|
本帖最后由 fengchen 于 2023-12-8 22:02 编辑
20231208
opnsense上设置wg小记:
官方有个说明https://docs.opnsense.org/manual/how-tos/wireguard-client.html
注意如果wg只使用ipv4的话,Step 5(b)跳过不用设置
按这个说明会出现tp路由器不能访问的问题,应该是tp阻止了wg地址段ip的访问,
对比了openwrt的wg设置,最后添加snat后正常,设置如下:
firewall - nat - outbound:
Select - Hybrid outbound NAT rule generation
Add rule - interface: lan, tcp/ip: ipv4, source address: wg net, destination address: lan net, translation/target: lan address
=================================================
20230827
最近准备把出口路由换成opnsense防火墙,因为它更新更快些,而且有几个流量图形界面比较合我的意,openwrt下就是找不到合适的流量图形显示软件
再记录下遇到的坑
这私对硬盘读写较多,日志也很全面,所以用u盘的话就不太行(太慢),得上ssd才好
还有一个就是,添加开机启动脚本时不能像原生freebsd那样,那样死活不调用
opnsense有一个专门的目录用来放自启动脚本,参考https://docs.opnsense.org/development/backend/autorun.html,
这样就好办了,在/usr/local/etc/rc.syshook.d/start/目录做一个脚本20-autostart,注意添加执行权限,内容如下
- root@OPNsense:~ # cat /usr/local/etc/rc.syshook.d/start/20-autostart
- #!/bin/sh
- sh /etc/rc.local
复制代码 这样/etc/rc.local就可以愉快的使用了
然后运行两天后,又发现wan不定时断线,后来干脆拨不上号了,重启后正常
查看log发现ppp发送包一直没有响应,再看系统日志发现有
- 2023-08-27T12:52:06 Notice kernel <6>re1: link state changed to UP
- 2023-08-27T12:52:02 Notice kernel <6>re1: link state changed to DOWN
- 2023-08-27T12:52:02 Notice kernel <6>re1: watchdog timeout
- 2023-08-27T12:51:55 Notice kernel <6>re1: link state changed to UP
- 2023-08-27T12:51:51 Notice kernel <6>re1: link state changed to DOWN
- 2023-08-27T12:51:51 Notice kernel <6>re1: watchdog timeout
- 2023-08-27T12:51:33 Notice kernel <6>re1: link state changed to UP
- 2023-08-27T12:51:29 Notice kernel <6>re1: link state changed to DOWN
- 2023-08-27T12:51:29 Notice kernel <6>re1: watchdog timeout
- 2023-08-27T12:51:20 Notice kernel <6>re1: link state changed to UP
- 2023-08-27T12:51:16 Notice kernel <6>re1: link state changed to DOWN
- 2023-08-27T12:51:16 Notice kernel <6>re1: watchdog timeout
复制代码
网卡看门狗超时导致一直down/up,咱也不知道啥情况,放鸽一搜,TNND,驱动的问题,再细爬,opnsense官方有螃蟹驱动插件
先装上os-realtek-re看看效果吧
详见https://forum.opnsense.org/index.php?topic=26627.0
================================================================================================
1。https://opnsense.org/download/ 直接下载nano版本的镜像,用rufus写入u盘就可以启动
Select the image type:
dvd: ISO installer image with live system capabilities running in VGA mode. On amd64, UEFI boot is supported as well.
vga: USB installer image with live system capabilities running in VGA mode as GPT boot. On amd64, UEFI boot is supported as well.
serial: USB installer image with live system capabilities running in serial console (115200) mode as MBR boot.
nano: a preinstalled serial image for USB sticks, SD or CF cards as MBR boot. These images are 3G in size and automatically adapt to the installed media size after first boot.
这里有个比较坑的地方,如果下载的VGA或者DVD安装文件,默认启动的是livecd模式,要在控制台使用用户名installer密码opnsense登陆后安装
Default behaviour is to start the Live environment, to install log in with user installer and password opnsense
2。启动过程中不要动键盘,直到输入用户名登陆,用户名root密码opnsense,ifconfig|more可以查看lan口的ip和mac,就知道怎么插网线了
3。web菜单System: Wizard这个是初次设置向导,错过的话可以点这里
4。System: Firmware更新系统,mirror可以选择中国的那个,web界面点击后经常卡顿,可能是我的硬件性能没达到推荐要求
5。ipv6推荐设置(SLAAC):
Interfaces: [WAN] - IPv6 Configuration Type:dhcpv6, Use IPv4 connectivity:Y, Prefix delegation size:60(根据ISP提供的,重要)
Interfaces: [LAN]- IPv6 Configuration Type:Track interface, Manual configuration:Y
Services: DHCPv6: [LAN] -Enable:N, Services: Router Advertisements: [LAN] - Router Advertisements:Unmanaged
Interfaces: Overview可以查看接口详细信息
6。端口转发:
Firewall: NAT: Port Forward - Interface:wan, TCP/IP Version:ipv4, Protocol:tcp, Destination:WAN address, Destination port range: from,other,12345 to,other,23456
- Redirect target IP:single host or network,192.168.10.10, Redirect target port: other,12345(这里自动对应范围了), NAT reflection:enable(NAT回流,还要加上下面的设置)
NAT回流添加设置:Firewall: Settings: Advanced - Reflection for port forwards:Y, Automatic outbound NAT for Reflection:Y
7。ipv6防火墙规则rules:
Firewall: Aliases - Name:debian_ipv6, Type:dynamic ipv6 host, Content: ::1:2:3:4, Interface:lan,Firewall: Rules: WAN - Action:pass, Interface:wan, Direction:in, TCP/IP Version:ipv6, Protocol:tcp, Destination:debian_ipv6, Destination port range: from,other,12345 to,other,23456
8。总结,设置过程比较反人性化,大家家用还是openwrt吧
9。点了一下wan口pppoe disconnect再也拨不上号了,弄了半天发现配置给搞丢了
|
评分
-
查看全部评分
|