【问题标题】:iptables redirect udp syslog to another IP address Not forwardingiptables 将 udp 系统日志重定向到另一个 IP 地址 不转发
【发布时间】:2014-01-27 13:15:03
【问题描述】:

我有一个愚蠢的问题。我正在一个新设施中安装一个新的系统日志收集服务器。我们有许多不同类型的设备,我们在同一个端口上收集系统日志。所以我必须将单个 IP 重定向到一个新的 IP 地址。这是一个临时解决方案,直到我们有人力登录每个设备并在单个设备中创建所需的更改。问题是我们正在重定向的一些传入 IP 工作。有些不。

我想做的是以下 Y.Y.Y.Y:514 转发到 X.X.X.X:514

我在允许源 74.93.xxx.xxx 目标 208.67.xxx.xxx 目标端口 514 中有一个 iptable 规则。然后我有一个包含以下信息的预路由 iptables -t nat -A PREROUTING -i eth0 -s 74.93.xxx.xxx -p udp --dport 514 -j DNAT --to-destination 209.173.xxx.xxx:514 -m comment --comment BAC:NameY

从我的iptables视图可以看到169M已经传入,这里是那个输出视图

[root@XXXXX ~]# iptables -L -v -n --line-numbers
Chain INPUT (policy ACCEPT 79M packets, 29G bytes)
num   pkts bytes target     prot opt in     out     source               destination
1     572K  169M ACCEPT     udp  --  eth0   *       74.93.xxx.xxx        208.67.xxx.xxx      udp dpt:514 /* NameY */
2     115M   25G ACCEPT     udp  --  *      *       0.0.0.0/0            0.0.0.0/0           udp dpt:514

Chain FORWARD (policy ACCEPT 239M packets, 63G bytes)
num   pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 29M packets, 11G bytes)
num   pkts bytes target     prot opt in     out     source               destination

在我的预路由链中,我没有看到该 DNAT 的任何数据包,这是输出视图:

[root@XXXXX ~]# iptables -t nat -L -n -v --line-numbers
Chain PREROUTING (policy ACCEPT 107K packets, 33M bytes)
num   pkts bytes target     prot opt in     out     source               destination
1        0     0 DNAT       udp  --  eth0   *       74.93.xxx.xxx        0.0.0.0/0           udp dpt:514 /* NameY */ to:209.173.xxx.xxx:514
2     3468  676K DNAT       udp  --  eth0   *       205.201.xxx.xxx      0.0.0.0/0           udp dpt:514 /* NameB */ to:209.173.xxx.xxx:514
3    80425   21M DNAT       udp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           udp dpt:516 to:209.173.xxx.xxx:514

Chain POSTROUTING (policy ACCEPT 162 packets, 9467 bytes)
num   pkts bytes target     prot opt in     out     source               destination
1     188K   28M MASQUERADE  all  --  *      eth0    0.0.0.0/0            0.0.0.0/0

Chain OUTPUT (policy ACCEPT 107K packets, 6473K bytes)
num   pkts bytes target     prot opt in     out     source               destination

这是我正在使用的服务器的一些信息 服务器是带有 32GB 内存的 Dell Poweredge 2950 上的 Redhat Ent 5 Linux 2.6.18-348.el5 #1 SMP 2012 年 11 月 28 日星期三 21:22:00 EST x86_64 x86_64 x86_64 GNU/Linux

这是我的 sysctl [root@XXXX ~]# cat /etc/sysctl.conf # Red Hat Linux 的内核 sysctl 配置文件 # # 对于二进制值,0 禁用,1 启用。参见 sysctl(8) 和 # sysctl.conf(5) 了解更多详情。

# Controls IP packet forwarding
net.ipv4.ip_forward = 1

# Controls source route verification
net.ipv4.conf.default.rp_filter = 1

# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0

# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0

# Controls whether core dumps will append the PID to the core filename
# Useful for debugging multi-threaded applications
kernel.core_uses_pid = 1

# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1

# Controls the maximum size of a message, in bytes
kernel.msgmnb = 65536

# Controls the default maxmimum size of a mesage queue
kernel.msgmax = 65536

# Controls the maximum shared segment size, in bytes
kernel.shmmax = 68719476736

# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 4294967296

我做错了什么,为什么我不能将74.93.xxx.xxx转发到新IP? 感谢您的帮助,欢迎所有的cmets。

高尔基体

【问题讨论】:

  • 你能提供ifconfig的输出吗?
  • 请看我的回答,谢谢
  • table filter 有很多包,但是table nat 中的包很少。主机在添加 DNAT 规则之前是否可能收到 169M 的数据包?

标签: udp iptables syslog forward


【解决方案1】:

这是我的 ifconfig 的输出。出于安全原因,我更改了一些信息

[root@myname ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:24:E8:62:AE:2F
          inet addr:208.67.xxx.xxx Bcast:208.67.xxx.yyy  Mask:255.255.255.224
          inet6 addr: fe80::124:e6ff:fe51:ae8f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:764714795 errors:0 dropped:23 overruns:0 frame:0
          TX packets:436520147 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:218689483470 (203.6 GiB)  TX bytes:125953479839 (117.3 GiB)
          Interrupt:169 Memory:f8000000-f8012800

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:5290847 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5290847 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3124832137 (2.9 GiB)  TX bytes:3124832137 (2.9 GiB)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-14
    • 2023-03-13
    • 2021-06-24
    • 2021-08-27
    • 1970-01-01
    相关资源
    最近更新 更多