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

simple routing don't work under debian jessie

· 52CE 我爱测

I'm trying to set up simple enogh system with 3 virtual debian jessie machines: first connected to second and second connected to third. I want first one to be able ping third one. To achieve this, I've set up static IP addresses…

问题原文

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

I'm trying to set up simple enogh system with 3 virtual debian jessie machines: first connected to second and second connected to third. I want first one to be able ping third one.

To achieve this, I've set up static IP addresses (via /etc/network/interfaces) like this:

#FIRST:
eth0 inet static address 172.28.11.2 netmask 255.255.255.0
#SECOND: 
eth0 inet static address 172.28.11.1 netmask 255.255.255.0
eth1 inet static address 172.28.18.2 netmask 255.255.255.0
#THIRD:
eth0 inet static address 172.28.18.1 netmask 255.255.255.0

Also I've enabled ipv4_forward option in all these machines:

net.ipv4.ip_forward=1 # /etc/sysctl.conf, all machines

and checked that it works (by invoking cat /proc/...../ip_forward and ensuring there is 1 in output)

First can ping second (checked, works). Second can ping third (checked, works).

Now I'm trying to set up simple routing table: I'm adding this route on first node:

route add -net 172.28.18.0 netmask 255.255.255.0 dev eth0 gw 172.28.11.1

After it I can ping 172.28.11.2 (second node in other network mask) but still can't reach 172.28.11.1 (third node).

If I do traceroute I see that there IS a 172.28.11.1 hop in route (so it TRIES to connect there) but no luck.

What I've missed?

P.S. My config: windows 10 as host, vmware player as virtualization, debian 8 as all guests

已采纳解答

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

As you don't mention you added a route on the third system, I'm guessing the problem is that the third system doesn't know how to route return packets to 172.28.11.0/24. So you need to add a route there.

Note that the route command has been deprecated in linux for a very long time now. You should familiarize yourself with the ip command, it is very powerful and you can do all sorts of interesting routing tricks with it.

You can add the required route on the third system thusly:

ip route add 172.28.11.0/24 via 172.28.18.2

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

资料来源与适用范围

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

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

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