免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: door10000
打印 上一主题 下一主题

[OpenBSD] openbsd做网关路由问题 [复制链接]

论坛徽章:
2
摩羯座
日期:2014-05-26 12:02:462015年辞旧岁徽章
日期:2015-03-03 16:54:15
11 [报告]
发表于 2013-05-07 22:32 |只看该作者
  1. # vi /etc/pf.conf
  2. #pass out log on egress proto tcp to any port smtp


  3. #block in quick from urpf-failed to any # use with care

  4. # By default, do not permit remote connections to X11
  5. block in on ! lo0 proto tcp to port 6000:6010
  6. ext_if="tun0"
  7. int_if="re1"
  8. internal_net="192.168.1.0/24"

  9. # for NAT
  10. pass out on re0 from 192.168.1.0/24 to any nat-to 10.10.12.100
  11. pass out on re0 from re1:network to any nat-to re0

  12. # for firewall
  13. block in all
  14. block out all
  15. pass quick on lo0 all
  16. pass out on $ext_if proto tcp all modulate state flags S/SA
  17. pass out on $ext_if proto { udp,icmp } all keep state
  18. pass in on $int_if from $internal_net to any
  19. pass out on $int_if from any to $internal_net

  20. # cat /etc/sysctl.conf
  21. #       $OpenBSD: sysctl.conf,v 1.53 2012/05/31 15:04:03 sthen Exp $
  22. #
  23. # This file contains a list of sysctl options the user wants set at
  24. # boot time.  See sysctl(3) and sysctl(8) for more information on
  25. # the many available variables.
  26. #
  27. net.inet.ip.forwarding=1        # 1=Permit forwarding (routing) of IPv4 packets
  28. #net.inet.ip.mforwarding=1      # 1=Permit forwarding (routing) of IPv4 multicast packets
  29. #net.inet.ip.multipath=1        # 1=Enable IP multipath routing
  30. #net.inet.icmp.rediraccept=1    # 1=Accept ICMP redirects
  31. #net.inet6.icmp6.rediraccept=1  # 1=Accept IPv6 ICMP redirects (for hosts)
  32. net.inet6.ip6.forwarding=1      # 1=Permit forwarding (routing) of IPv6 packets
  33. #net.inet6.ip6.mforwarding=1    # 1=Permit forwarding (routing) of IPv6 multicast packets
  34. #net.inet6.ip6.multipath=1      # 1=Enable IPv6 multipath routing
  35. #net.inet6.ip6.accept_rtadv=1   # 1=Permit IPv6 autoconf (forwarding must be 0)
  36. #net.inet.tcp.always_keepalive=1 # 1=Keepalives for all connections (e.g. hotel/airport NAT)
  37. #net.inet.tcp.keepidle=100      # 100=send TCP keepalives every 50 seconds
  38. #net.inet.tcp.rfc1323=0         # 0=Disable TCP RFC1323 extensions (for if tcp is slow)
  39. #net.inet.tcp.rfc3390=0         # 0=Disable RFC3390 for TCP window increasing
  40. #net.inet.esp.enable=0          # 0=Disable the ESP IPsec protocol
  41. #net.inet.ah.enable=0           # 0=Disable the AH IPsec protocol
  42. #net.inet.esp.udpencap=0        # 0=Disable ESP-in-UDP encapsulation
  43. #net.inet.ipcomp.enable=1       # 1=Enable the IPCOMP protocol
  44. #net.inet.etherip.allow=1       # 1=Enable the Ethernet-over-IP protocol
  45. #net.inet.tcp.ecn=1             # 1=Enable the TCP ECN extension
  46. #net.inet.carp.preempt=1        # 1=Enable carp(4) preemption
  47. #net.inet.carp.log=3            # log level of carp(4) info, default 2
  48. #ddb.panic=0                    # 0=Do not drop into ddb on a kernel panic
  49. #ddb.console=1                  # 1=Permit entry of ddb from the console
  50. #fs.posix.setuid=0              # 0=Traditional BSD chown() semantics
  51. #vm.swapencrypt.enable=0        # 0=Do not encrypt pages that go to swap
  52. #vfs.nfs.iothreads=4            # Number of nfsio kernel threads
  53. #net.inet.ip.mtudisc=0          # 0=Disable tcp mtu discovery
  54. #kern.usercrypto=1              # 1=Enable userland use of /dev/crypto
  55. #kern.userasymcrypto=1          # 1=Permit userland to do asymmetric crypto
  56. #kern.splassert=2               # 2=Enable with verbose error messages
  57. #kern.nosuidcoredump=2          # 2=Put suid coredumps in /var/crash
  58. #kern.watchdog.period=32        # >0=Enable hardware watchdog(4) timer if available
  59. #kern.watchdog.auto=0           # 0=Disable automatic watchdog(4) retriggering
  60. #kern.pool_debug=0              # 0=Disable pool corruption checks (faster)
  61. #hw.allowpowerdown=0            # 0=Disable power button shutdown
  62. machdep.allowaperture=2         # See xf86(4)
  63. #machdep.apmhalt=1              # 1=powerdown hack, try if halt -p doesn't work
  64. #machdep.kbdreset=1             # permit console CTRL-ALT-DEL to do a nice halt
  65. #machdep.lidsuspend=1           # laptop lid closes cause a suspend
  66. #machdep.userldt=1              # allow userland programs to play with ldt,
  67.                                 # required by some ports
  68. #kern.emul.aout=1               # enable running dynamic OpenBSD a.out bins
  69. #kern.emul.linux=1              # enable running Linux binaries
  70. #
复制代码

论坛徽章:
2
摩羯座
日期:2014-05-26 12:02:462015年辞旧岁徽章
日期:2015-03-03 16:54:15
12 [报告]
发表于 2013-05-07 22:34 |只看该作者
两份配置文档已给出,还有什么需要给出的吗?回复 7# f5b


   

论坛徽章:
0
13 [报告]
发表于 2013-05-07 23:17 |只看该作者
/etc/pf.conf

文件的内容?

论坛徽章:
2
摩羯座
日期:2014-05-26 12:02:462015年辞旧岁徽章
日期:2015-03-03 16:54:15
14 [报告]
发表于 2013-05-07 23:43 |只看该作者
  1. 01.# vi /etc/pf.conf

  2. 02.#pass out log on egress proto tcp to any port smtp

  3. 03.

  4. 04.

  5. 05.#block in quick from urpf-failed to any # use with care

  6. 06.

  7. 07.# By default, do not permit remote connections to X11

  8. 08.block in on ! lo0 proto tcp to port 6000:6010

  9. 09.ext_if="tun0"

  10. 10.int_if="re1"

  11. 11.internal_net="192.168.1.0/24"

  12. 12.

  13. 13.# for NAT

  14. 14.pass out on re0 from 192.168.1.0/24 to any nat-to 10.10.12.100

  15. 15.pass out on re0 from re1:network to any nat-to re0

  16. 16.

  17. 17.# for firewall

  18. 18.block in all

  19. 19.block out all

  20. 20.pass quick on lo0 all

  21. 21.pass out on $ext_if proto tcp all modulate state flags S/SA

  22. 22.pass out on $ext_if proto { udp,icmp } all keep state

  23. 23.pass in on $int_if from $internal_net to any

  24. 24.pass out on $int_if from any to $internal_net
复制代码
已经给出了。

论坛徽章:
0
15 [报告]
发表于 2013-05-08 09:50 |只看该作者
本帖最后由 f5b 于 2013-05-08 09:51 编辑

结合http://www.openbsd.org/faq/pf/example1.html
还有OpenBSD 5.3默认的/etc/pf.conf

请把你的/etc/pf.conf 更改为以下内容
测试re1所在局域网其他电脑能上网再慢慢修改自己想要的功能吧

  1. # increase default state limit from 10'000 states on busy systems
  2. #set limit states 100000

  3. int_if="re1"

  4. set skip on lo

  5. match out on egress inet from !(tun0:network) to any nat-to (tun0:0)

  6. block in
  7. pass out quick

  8. antispoof quick for { lo $int_if }

  9. pass in on $int_if

  10. # By default, do not permit remote connections to X11
  11. block in on ! lo0 proto tcp to port 6000:6010

复制代码
建议学习网址
http://www.openbsd.org/faq/pf/index.html
http://home.nuug.no/~peter/pf/

pppoe那里还可以参考我写的
http://bbs.chinaunix.net/thread-3850797-1-1.html

论坛徽章:
2
摩羯座
日期:2014-05-26 12:02:462015年辞旧岁徽章
日期:2015-03-03 16:54:15
16 [报告]
发表于 2013-05-08 10:51 |只看该作者
回复 15# f5b
谢谢大侠了,把pf配置档按你的一下就通了。不过我想问下那个十万是干什么用的?在忙碌系统中配置起什么作用?

   

论坛徽章:
2
摩羯座
日期:2014-05-26 12:02:462015年辞旧岁徽章
日期:2015-03-03 16:54:15
17 [报告]
发表于 2013-05-08 10:55 |只看该作者
我想配置一个限流2mb路线单个ip并用队列queue限制他们的上传流量要怎么配置?

论坛徽章:
2
摩羯座
日期:2014-05-26 12:02:462015年辞旧岁徽章
日期:2015-03-03 16:54:15
18 [报告]
发表于 2013-05-08 14:30 |只看该作者
另外我发现openbsd中的dhcp配置以后客户端只要获得了dns为网关地址就可以上外网但fb不可以哟一定要手动设置dns才能上外网。

论坛徽章:
1
寅虎
日期:2013-09-29 23:15:15
19 [报告]
发表于 2013-05-09 08:38 |只看该作者
回复 18# door10000


    看规则怎样设吧
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP