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

Basic forwarding on Ubuntu not working

· 52CE 我爱测

I have the following setup, minimized to explain the problem: _________ |Desktop | ---------- 192.168.2.6| | | ------------ |------------------ --------------| Switch | | Firewall server | ------------ |------------------ |192.16…

问题原文

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

I have the following setup, minimized to explain the problem:

                                 _________      
                                 |Desktop |    
                                 ----------     
                          192.168.2.6|               
                                     |              
                                     |              
                                 ------------          |------------------
                   --------------| Switch   |          |  Firewall server
                   |             ------------          |------------------
                   |192.168.2.110                          |         |
           ----------------                    192.168.1.11|         |To ISP
           |   Server     |---------------     ------------|         |------------
           ---------------- 192.168.1.121      |          
                                       |       |
                                      ------------
                                      |  Switch  |
                                      ------------

I have set default gateway on Desktop to 192.168.2.110

I have set default gateway on Server to 192.168.1.11

I have forwarding enabled on Server and Firewall server

I can ping from Desktop to Server and vice-versa

I can ping from Server to Firewall server and vice-versa.

I can ping from Desktop to 192.168.1.121 too.

I cannot ping from Desktop to Firewall server 192.168.1.11. I tried with all iptables rules flushed on all the machines shown. What am I missing?

EDIT: To provide more information, as requested. ALL machines are running Linux Ubuntu. The desktops are development machines. The server runs development servers... Mysql, PhP, Apache, etc. The Firewall server has a set of iptables rules which I disable when testing ping just to get to it.

已采纳解答

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

You need to add a route for the 192.168.2.0/24 network in your firewall. It should be something like:

route add -net 192.168.2.0/24 gw 192.168.1.121

Your firewall has no idea where to send a packet when it is coming from 192.168.2.0/24 network. The server can ping the firewall because it is directly connected over 192.168.1.121.

Actually, when you try to reach the firewall from the desktop, the packet is arriving at the firewall (given that the server also has default gw set to firewall ip 192.168.1.11) but the firewall can't send it back to the desktop, as there is no route for this network available. And it can only forward the packets to the default gateway to the ISP, which will be discarded at the end.

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

资料来源与适用范围

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

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

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