免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2631 | 回复: 9
打印 上一主题 下一主题

[OpenBSD] 求助OpenBSD PF NAT 无效 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-08-25 11:51 |只看该作者 |倒序浏览
我安装OpenBSD,在/etc/rc.conf中启用了 pf=YES
修改了/etc/sysctl.conf中 net.inet.ip.forwarding=1

然后创建了/etc/pf.conf,内容如下:
ext_if="fxp1"
int_if="fxp0"

nat on $ext_if from $int_if:network to any -> $ext_if





就这么简单的一行,前几天在FreeBSD下测试客户机还可以上网,但是换成OpenBSD就不行.
客户机可以ping到内外网口的IP.ping外网地址就不行.不知道怎么回事.请高手赐教.
谢谢!

论坛徽章:
0
2 [报告]
发表于 2008-08-25 11:55 |只看该作者

运行pfctl -sa 显示信息如下

# pfctl -sa
TRANSLATION RULES:
nat pass on fxp1 inet from 10.1.0.0/21 to any -> 2xx.xxx.xxx.xxx

FILTER RULES:
pass all flags S/SA keep state
No queue in use

INFO:
Status: Disabled                              Debug: Urgent

State Table                          Total             Rate
  current entries                        0               
  searches                               0            0.0/s
  inserts                                0            0.0/s
  removals                               0            0.0/s
Counters
  match                                  0            0.0/s
  bad-offset                             0            0.0/s
  fragment                               0            0.0/s
  short                                  0            0.0/s
  normalize                              0            0.0/s
  memory                                 0            0.0/s
  bad-timestamp                          0            0.0/s
  congestion                             0            0.0/s
  ip-option                              0            0.0/s
  proto-cksum                            0            0.0/s
  state-mismatch                         0            0.0/s
  state-insert                           0            0.0/s
  state-limit                            0            0.0/s
  src-limit                              0            0.0/s
  synproxy                               0            0.0/s

TIMEOUTS:
tcp.first                   120s
tcp.opening                  30s
tcp.established           86400s
tcp.closing                 900s
tcp.finwait                  45s
tcp.closed                   90s
tcp.tsdiff                   30s
udp.first                    60s
udp.single                   30s
udp.multiple                 60s
icmp.first                   20s
icmp.error                   10s
other.first                  60s
other.single                 30s
other.multiple               60s
frag                         30s
interval                     10s
adaptive.start             6000 states
adaptive.end              12000 states
src.track                     0s

LIMITS:
states        hard limit    10000
src-nodes     hard limit    10000
frags         hard limit     5000
tables        hard limit     1000
table-entries hard limit   200000

TABLES:
spamd-white

OS FINGERPRINTS:
696 fingerprints loaded
#

论坛徽章:
1
寅虎
日期:2013-09-29 23:15:15
3 [报告]
发表于 2008-08-25 12:27 |只看该作者
加上 pass all 如何?

论坛徽章:
0
4 [报告]
发表于 2008-08-25 12:58 |只看该作者
问题解决了,谢谢三楼的老大~~
是我自己犯错了!
我在/etc/rc.conf中,由于没有搜索到pf=YES,就加了一行,结果,发现下面有一行是pf=NO.不好意思啊...
本人新手,刚接触OPENBSD才1周时间.
不好意思....

论坛徽章:
0
5 [报告]
发表于 2008-08-25 13:03 |只看该作者

很漂亮的错误

论坛徽章:
1
寅虎
日期:2013-09-29 23:15:15
6 [报告]
发表于 2008-08-25 13:26 |只看该作者
原帖由 deanetg 于 2008-8-25 12:58 发表
问题解决了,谢谢三楼的老大~~
是我自己犯错了!
我在/etc/rc.conf中,由于没有搜索到pf=YES,就加了一行,结果,发现下面有一行是pf=NO.不好意思啊...
本人新手,刚接触OPENBSD才1周时间.
不好意思....

给个建议,保持/etc/rc.conf原状,把pf=YES添加到/etc/rc.conf.local.
两个字"清晰".

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
7 [报告]
发表于 2008-08-25 14:43 |只看该作者
原帖由 congli 于 2008-8-25 13:26 发表

给个建议,保持/etc/rc.conf原状,把pf=YES添加到/etc/rc.conf.local.
两个字"清晰".

呵呵

论坛徽章:
0
8 [报告]
发表于 2008-08-25 15:16 |只看该作者

新问题出来了~~

我按照PF手册进行设置.虽然NAT起作用了.但是好像外网口防火墙没有起作用,PING也可以PING到,SSH也可以登录.下面是我的配置文件:
# macros
ext_if="fxp1"
int_if="fxp0"
#dmz_net=""
proxy_ip="2xx.xxx.xxx.xxx"
loc_net="10.1.0.0/21"
pri_net="{192.168.0.0/16,127.0.0.0/8,172.16.0.0/12,10.0.0.0/8,169.254.0.0/16}"

icmp_types="echoreq"

# Servers


# tables
table <spamd-white> persist

# options
#set skip on lo
set block-policy drop
set loginterface $ext_if
set optimization normal
set timeout interval 10
set timeout frag 30


# scrub
#scrub in on $ext_if all
scrub in all

# nat
nat on $ext_if inet from $int_if:network to any -> $proxy_ip


# redirections


# filters
block drop all

pass quick on lo0 all

# SSH login
pass in  on $int_if inet proto tcp from $loc_net to $int_if port 22 keep state
pass out on $int_if inet proto tcp from $int_if to $loc_net port 22 keep state

#pass in inet proto icmp all icmp-type $icmp_types keep state


pass in on $int_if from $int_if:network to any keep state
pass out on $int_if from any to $int_if:network keep state

block drop in quick on $ext_if from $pri_net to any
block drop out quick on $ext_if from any to $pri_net

pass out on $ext_if proto tcp all modulate state flags S/SA
pass out on $ext_if proto {udp,icmp} all keep state

论坛徽章:
0
9 [报告]
发表于 2008-08-25 15:17 |只看该作者

运行 pfctl -sr 的结果如下:

# pfctl -sr
scrub in all fragment reassemble
block drop all
pass quick on lo0 all flags S/SA keep state
pass in on fxp0 inet from 10.1.0.0/21 to any flags S/SA keep state
pass out on fxp0 inet from any to 10.1.0.0/21 flags S/SA keep state
block drop in quick on fxp1 inet from 192.168.0.0/16 to any
block drop in quick on fxp1 inet from 127.0.0.0/8 to any
block drop in quick on fxp1 inet from 172.16.0.0/12 to any
block drop in quick on fxp1 inet from 10.0.0.0/8 to any
block drop in quick on fxp1 inet from 169.254.0.0/16 to any
block drop out quick on fxp1 inet from any to 192.168.0.0/16
block drop out quick on fxp1 inet from any to 127.0.0.0/8
block drop out quick on fxp1 inet from any to 172.16.0.0/12
block drop out quick on fxp1 inet from any to 10.0.0.0/8
block drop out quick on fxp1 inet from any to 169.254.0.0/16
pass out on fxp1 proto tcp all flags S/SA modulate state
pass out on fxp1 proto udp all keep state
pass out on fxp1 proto icmp all keep state

论坛徽章:
0
10 [报告]
发表于 2008-10-22 17:27 |只看该作者
你的错误很有用,看了你的错误,我就没犯跟你一样的错误了,谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP