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

SNMP port forwarding one way

· 52CE 我爱测

I would like to forward snmp from one LAN to another LAN. I believe I got one way working (from outside to inside), but sadly the box1 cannot seem to reply. (inside to outside) The setup I would like to make : box1 box2 box3 [10.…

问题原文

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

I would like to forward snmp from one LAN to another LAN. I believe I got one way working (from outside to inside), but sadly the box1 cannot seem to reply. (inside to outside)

The setup I would like to make :

  box1                  box2             box3
[10.1.255.245] -------------------------- [public_ip]
    |               eth0-|-eth1               |
    |-----------3161---------------- 3161 ----|

These are the iptables rules which are relevant of BOX 2,

-A PREROUTING -i eth1 -p udp -m udp --dport 3161 -j DNAT --to-destination 10.1.255.244:3161
-A FORWARD -d 10.1.255.244/32 -p udp -m udp --dport 3161 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT

Now I validated that packages coming from box3 are received in box1.

tcpdump 'port 3161'
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
13:46:03.887718 IP x-20150810-092601.x.be.53329 > compute-0-2.local.doc1lm: UDP, length 48
13:46:04.888851 IP x-20150810-092601.x.be.53329 > compute-0-2.local.doc1lm: UDP, length 48
13:46:05.889977 IP x-20150810-092601.x.be.53329 > compute-0-2.local.doc1lm: UDP, length 48
13:46:06.891108 IP x-20150810-092601.x.be.53329 > compute-0-2.local.doc1lm: UDP, length 48

So I assume the snmp process cannot respond to the location cause it does not know how to find this out-of-lan ip... how can I add this ? this is route on box1 :

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
255.255.255.255 *               255.255.255.255 UH    0      0        0 eth0
box2 box2     255.255.255.255 UGH   0      0        0 eth0
224.0.0.0       *               255.255.255.0   U     0      0        0 eth0
10.1.0.0        *               255.255.0.0     U     0      0        0 eth0
link-local      *               255.255.0.0     U     1002   0        0 eth0
link-local      *               255.255.0.0     U     1003   0        0 eth1
192.168.0.0     *               255.255.0.0     U     0      0        0 eth1
default         storage          0.0.0.0         UG    0      0        0 eth1

Or am I missing something else obvious ?

已采纳解答

原帖链接 · Alexander Tolkachev · CC BY-SA 3.0

SNMP working trough UDP, so there is no sessions, like in TCP. So you should add additional NAT entry on box2 to allow packets from box1 to box3.

Something like this:

-A PREROUTING -i eth0 -p udp -m udp --dport 3161 -j DNAT --to-destination <RealIP>:3161
-A FORWARD -d <RealIP>/32 -p udp -m udp --dport 3161 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT

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

资料来源与适用范围

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

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

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