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

Command-line utility to test fwmark in ip rule / ip route?

· 52CE 我爱测

I am trying to find a tool that will allow me to find the route a packet will take that comes in on a device, and has a particular destination address. ip route get will do most of what I am looking for. The issue is that I would…

问题原文

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

I am trying to find a tool that will allow me to find the route a packet will take that comes in on a device, and has a particular destination address.

ip route get will do most of what I am looking for.

The issue is that I would like to test whether packets are finding the right routes when they have a fwmark in a rather complicated routing environment.

The ideal tool would allow spoofing a generic packet with a fwmark (or other properties) and could either send it through the entire IpTables chains and the ip route / ip rule sets, or just find the route that would be returned.

I'd like to be able to run a command to verify that a particular set of routes works as intended.

Minimum requirement would be something like ip route get but with fwmark support.

Although, at this point, any suggestions for testing utilities of routing would be greatly appreciated! It gets complicated rather quickly as the routes pile up.

已采纳解答

原帖链接 · Anton Danilov · CC BY-SA 3.0

You can use the mark option in the 'ip route get' command. Also you can specify source-address and input and output intefaces in this command.

Examples:

ip route get 8.8.8.8 mark 0x20 - check the route of marked packets to 8.8.8.8 address.

ip route get 8.8.8.8 from 192.168.0.200 iif eth1 - check the route of forwarded packets from 192.168.0.200 host received through eth1 interface. In this case you should specify iif if the 'from' address isn't on this host (not local).

ip route get 8.8.8.8 from 192.168.0.100 iif eth1 mark 0x30 - like previous example, but with the mark specifying.

To test the path of packets through the netfilter rule set you can use the TRACE target and scapy to construct desired packets.

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

资料来源与适用范围

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

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

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