大网数据广告活动
服务器运维问答

How do I set up an IPv6 DMZ with iptables without a static allocation?

· 52CE 我爱测

I have several networks which are on Comcast's residential network. I need to access those networks from a variety of environments, via an SSH proxy on one of the hosts. (As it happens I'm using OpenWRT, so a specific solution th…

问题原文

原帖链接 · Glyph · CC BY-SA 3.0

I have several networks which are on Comcast's residential network. I need to access those networks from a variety of environments, via an SSH proxy on one of the hosts.

(As it happens I'm using OpenWRT, so a specific solution there would be helpful; but I'm also generally curious how one does this with any Linux or BSD-based edge routing solution.)

With IPv4, this is relatively straightforward: since all my internal IPs are allocated with DHCP, I can simply set up a forwarding rule to move port 22 on the external interface to port 22 on a specific IP.

Since my IPv6 addresses are all allocated with SLAAC, I don't have a static address that I can use in ip6tables-land to forward things.

How can I detect changes to the prefix allocation so that I can establish new iptables rules? Or is there a way to set up a rule which forwards to a particular host based on discovering its IP address from its MAC address or something like that? (These hosts are all on a single segment so multicast and such should work.)

已采纳解答

原帖链接 · Alexey Vazhnov · CC BY-SA 4.0

I think in your case you can use Dynamic prefix forwarding, my example of rule in /etc/config/firewall:

config rule
    option name 'HTTP-SSH-IPv6-myserver01'
    option src 'wan'
    option proto 'tcp'
    option dest 'lan'
    option dest_ip '::2c18:81a2:3422:f690/-64'
    option dest_port '22 80 443'
    option family 'ipv6'
    option target 'ACCEPT'

which creates iptables rule(s) like this:

-A zone_wan_forward -d ::2c18:81a2:3422:f690/::ffff:ffff:ffff:ffff -p tcp -m tcp --dport 80 -m comment --comment "!fw3: HTTP-IPv6-myserver01" -j zone_lan_dest_ACCEPT

Here is also described the same case: Dynamic IPv6 Subnet & ip6tables.

So it is even more easy than IPv4 — you don't need to configure static IP-addresses at your DHCP server.

P.S.: "DMZ" in title confused me at the first reading of question.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2014-06-13)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。