使用 iptables 将流量转发到单个 IP 地址

使用 iptables 将流量转发到单个 IP 地址

设置:

Debian;使用 iptables、fail2ban 充当网络路由器 由于外部要求,两个网络都是 192.168.1.x。eth0:192.168.1.1 eth1:192.168.1.2

Ubuntu(192.168.1.3)充当某种网络桥接 eth0:192.168.1.3 wlan0:192.168.1.10

连接到交换机的客户端计算机(192.168.1.100 至 200)

我的内部网络上的 Debian 的 eth0(192.168.1.1)与客户端计算机、台式计算机、无线设备等一起连接到交换机。

eth1 直接连接到 Ubuntu 的 eth0。

我可以从 Debian ping 和 SSH 到 Ubuntu,没有任何问题。当我尝试从其中一台客户端计算机(连接到 Debian 的 eth0)ping 或 SSH 时,我的连接超时了。

我不确定是否应该使用路由(或者完全确定如何使用路由)或 iptables 将流量从 Debian 的 eth0 传输到 eth1 并传输到 Ubuntu。

这是我的 iptables 输出:

Chain INPUT (policy DROP 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0
    0     0 ACCEPT     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
    0     0 ACCEPT     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           state NEW

Chain FORWARD (policy DROP 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     all  --  eth1   eth0    0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
    0     0 ACCEPT     all  --  eth2   eth0    0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
    0     0 ACCEPT     all  --  eth0   eth1    0.0.0.0/0            0.0.0.0/0
    0     0 REJECT     all  --  eth1   eth1    0.0.0.0/0            0.0.0.0/0           reject-with icmp-port-unreachable

非常感谢您的帮助。谢谢!

答案1

您是否桥接了 Debian 机器上的接口?如果没有,哪个接口有 IP 地址192.168.1.2。Debian 机器上的其他接口有哪个 IP 地址?请在问题中添加此信息。

由于问题不完整,我只能“猜测”你的 Debian 上的路由表混淆了,因为你为 Debian 盒的 2 个非桥接接口分配了相同的 IP 网络地址(甚至是相同的 IP 地址)。

如果确实是问题所在,则应将 ubuntu - debian 连接上的 ip 网络更改为其他 C 类网络。假设 192.168.2. / 255.255.255.0,那么 debian eth1 会有192.168.2.3,而 ubuntu 会得到192.168.2.4

然后,您应该能够通过键入从您的客户端访问 ubuntu 框 ,即使您的所有客户端都在 192.168.1.xxx/255.255.255.0 ip 网络中。ssh [email protected]

相关内容