zer*_*eck 5 iptables networking routing dns nat
更正3:解决了!我需要将我部门 VLAN 的官方 DNS 服务器作为 DNS 添加到客户端。
我已经阅读了大量关于使用 Linux 作为路由器时 iptables 问题的帖子,但没有一个可以帮助我解决以下问题:
我正在我们大学部门设置许多学生工作站,我们在 VLAN 中拥有有限的 IP。工作站需要相互通信并联机。明确地不应从 Internet 访问它们。我想使用以下设置,而不是为每个工作站提供大学 VLAN 中罕见的 IP 之一:
我们有一台运行 Ubuntu 14.04 服务器的服务器,带有 4 个以太网端口(我使用 2 个进行此设置)。
第一个端口是 em1,与所有工作站一起插入 L2 交换机。
第二个端口是 em2 并插入大学 VLAN。
首先是问题,然后是我的设置:
更正: wget/apt-get 的东西似乎只在某些时候有效。
更正 2:我至少在一个客户端的 DNS 条目之一中有错字,我将在明天尝试其余的条目,然后将其标记为已关闭。
设置等:
我通过取消注释net.ipv4.ip_forward=1在内核中激活了转发
/etc/sysctl.conf。
我/etc/network/interfaces的 2 个以太网端口条目如下所示:
auto em2
iface em2 inet static
address x.x.x.x
netmask x.x.x.x
network x.x.x.x
gateway x.x.x.x
dns-nameservers x.x.x.x x.x.x.x
dns-search x.example.com
pre-up iptables-restore < /etc/network/iptables.up.rules
post-down iptables-save > /etc/network/iptables.up.rules
auto em1
iface em1 inet static
address 192.168.99.252
netmask 255.255.255.128
pre-up iptables-restore < /etc/network/iptables.up.rules
post-down iptables-save > /etc/network/iptables.up.rules
Run Code Online (Sandbox Code Playgroud)
(出于隐私原因,对 em2 参数进行了编辑,但我认为它们在这里不起作用。请注意我们有两个内部 DNS 服务器,这可能在问题中起作用吗?)
我也有设置 iptables,sudo iptables -t nat -A POSTROUTING -o em2 -j MASQUERADE
所以sudo iptables -t nat -L给了我:
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- anywhere anywhere
MASQUERADE all -- anywhere anywhere
Run Code Online (Sandbox Code Playgroud)
(第二个条目一定是偶然发生的,但不应该令人担忧,对吧?)
所有客户端都具有以下设置的静态 IP:
解决方案是将我部门 VLAN 中的官方 DNS 条目添加到客户端 DNS 条目中。路由器未配置为单独用作 DNS,也未将 DNS 请求重定向到外部 DNS。因此对于每个客户端: - DNS:外部网络的官方 VLAN DNS
| 归档时间: |
|
| 查看次数: |
10271 次 |
| 最近记录: |