游乐游手机版
首页/系统平台/文章详情

FreeBSD双线负载均衡NAT服务器配置详解

时间:2026-06-18 07:51
vi etc rc conf ================+==============+================= defaultrouter= "221 33 88 254 " ifconfig_fxp0= "inet 192 168 0 1 netmask 255 255 255
# vi /etc/rc.conf

================+==============+=================

defaultrouter="221.33.88.254"
ifconfig_fxp0="inet 192.168.0.1 netmask 255.255.255.0"
ifconfig_rl0="inet 221.33.88.2 netmask 255.255.255.0"
ifconfig_rl1="inet 202.0.57.1 netmask 255.255.255.0"
pf_enable="YES"

================+==============+=================
# vi /etc/pf.conf

================+==============+=================

##anchors
lan_net = "192.168.0.0/24"
int_if  = "fxp0"
ext_if1 = "rl0"
ext_if2 = "rl1"
ext_gw1 = "221.33.88.254"
ext_gw2 = "61.0.57.254"

##nat outgoing connections on each internet interface
nat on $ext_if1 from $lan_net to any -> ($ext_if1)
nat on $ext_if2 from $lan_net to any -> ($ext_if2)

##default deny
block in  from any to any
block out from any to any

##pass all outgoing packets on internal interface
pass out on $int_if from any to $lan_net

##pass in quick any packets destined for the gateway itself
pass in quick on $int_if from $lan_net to $int_if

##load balance outgoing tcp traffic from internal network. 
pass in on $int_if route-to \
{ ($ext_if1 $ext_gw1), ($ext_if2 $ext_gw2) } round-robin \
proto tcp from $lan_net to any flags S/SA modulate state

##load balance outgoing udp and icmp traffic from internal network
pass in on $int_if route-to \
{ ($ext_if1 $ext_gw1), ($ext_if2 $ext_gw2) } round-robin \
proto { udp, icmp } from $lan_net to any keep state

##general "pass out" rules for external interfaces
pass out on $ext_if1 proto tcp from any to any flags S/SA modulate state
pass out on $ext_if1 proto { udp, icmp } from any to any keep state
pass out on $ext_if2 proto tcp from any to any flags S/SA modulate state
pass out on $ext_if2 proto { udp, icmp } from any to any keep state

##route packets from any IPs on $ext_if1 to $ext_gw1 and the same for
##$ext_if2 and $ext_gw2
pass out on $ext_if1 route-to ($ext_if2 $ext_gw2) from $ext_if2 to any 
pass out on $ext_if2 route-to ($ext_if1 $ext_gw1) from $ext_if1 to any

================+==============+=================
# vi /etc/sysctl.conf

net.inet.ip.forwarding=1
来源:https://www.jb51.net/os/Unix/1540.html
上一篇FreeBSD 6.2使用freebsd-update升级教程 下一篇FreeBSD系统下读写NTFS分区指南
本站内容用于信息整理与展示,如有侵权或内容问题请及时联系处理。

相关推荐

补充同频道和同主题内容,方便继续浏览更多相关内容。

同类最新

继续查看同栏目最近更新的文章。

更多
微软详解Win11时间点还原 默认每24小时创建恢复点
系统平台 · 2026-06-30

微软详解Win11时间点还原 默认每24小时创建恢复点

微软今日推送了最新的 6 月可选更新,并发布博客详细解读了 Win11 全新的“时间点还原”(Point-in-time restore)功能——这一功能本质上是对系统恢复体验的一次全面升级,旨在让用户更轻松地应对电脑故障。 微软表示,面向 Windows 11 客户端用户的“时间点还原”功能现已正

Win11 26H1六月可选更新KB5095091 优化放大镜改善装机体验
系统平台 · 2026-06-30

Win11 26H1六月可选更新KB5095091 优化放大镜改善装机体验

微软今天推送了Windows 11 26H1设备的6月可选更新KB5095091,安装完成后系统版本号会升级到Build 28000 2340。值得一提的是,这次更新并非面向所有设备,而是专门为搭载高通骁龙X2系列芯片的机型准备的——包括骁龙X2 Plus、X2 Elite和X2 Elite Ext

Win11六月可选更新KB5095093修复回收站弹窗异常
系统平台 · 2026-06-30

Win11六月可选更新KB5095093修复回收站弹窗异常

微软已悄然推送Windows 11六月可选更新,编号KB5095093。本次更新覆盖两个版本:24H2用户安装后版本号升级至Build 26100 8737,而25H2用户则更新至Build 26200 8737。 本次更新并非仅是小修小补,而是带来了多项实质性新功能。下面我们就来详细解析这些更新内

苹果macOS 27 Beta2封堵Siri AI跳过候补名单漏洞
系统平台 · 2026-06-30

苹果macOS 27 Beta2封堵Siri AI跳过候补名单漏洞

科技媒体 Cult of Mac 昨日(6月23日)发布博文指出,苹果在 macOS 27 Beta 2 更新中悄然封堵了一个此前可用的后门——用户曾能通过一条终端命令绕过候补名单,直接启用新版 Siri AI,如今这一方法已失效。 简要回顾一下:在 macOS 27 Beta 1 阶段,只需在 M

微软加速Win11 25H2推送 覆盖所有符合条件家用PC
系统平台 · 2026-06-30

微软加速Win11 25H2推送 覆盖所有符合条件家用PC

近日(6月23日),科技媒体 Windows Latest 发布了一则值得关注的动态:微软已进一步扩大 Windows 11 25H2 的推送范围,所有满足硬件要求、且不受 IT 部门管理的家庭版和专业版设备,现在均可顺利接收本次更新。 此次升级有一个显著特点——采用“启用包”(eKB)方式进行推送