IPtables의 TRACE 대상을 사용하려고하는데 추적 정보가 기록되지 않는 것 같습니다. 여기에 설명 된 것을 사용하고 싶습니다 :
Iptables 용 디버거 .
TRACE의 iptables 맨에서 :
This target marks packes so that the kernel will log every rule which match the packets as those traverse the tables, chains, rules. (The ipt_LOG or ip6t_LOG module is required for the logging.) The packets are logged with the string prefix: "TRACE: tablename:chain- name:type:rulenum " where type can be "rule" for plain rule, "return" for implicit rule at the end of a user defined chain and "policy" for the policy of the built in chains. It can only be used in the raw table.
다음 규칙을 사용 iptables -A PREROUTING -t raw -p tcp -j TRACE
하지만 / var / log / syslog 또는 /var/log/kern.log에 추가 된 것은 없습니다!
다른 단계가 누락 되었습니까? 내가 잘못된 장소를보고 있습니까?
편집하다
로그 항목을 찾을 수 없지만 패킷 카운터가 증가하므로 TRACE 대상이 올바르게 설정된 것 같습니다.
# iptables -L -v -t raw
Chain PREROUTING (policy ACCEPT 193 packets, 63701 bytes)
pkts bytes target prot opt in out source destination
193 63701 TRACE tcp -- any any anywhere anywhere
Chain OUTPUT (policy ACCEPT 178 packets, 65277 bytes)
pkts bytes target prot opt in out source destination
편집 2
규칙 iptables -A PREROUTING -t raw -p tcp -j LOG
은 패킷 정보를 / var / log / syslog에 인쇄합니다. 왜 TRACE가 작동하지 않습니까?
답변
운영:
modprobe ipt_LOG
그것은 나를 위해 그것을 고쳤다.
답변
새로운 커널에서는 (IPv4의 경우) 다음과 같이 보입니다 (즉, 저에게 효과적입니다).
modprobe nf_log_ipv4
sysctl net.netfilter.nf_log.2=nf_log_ipv4
크레딧 :
- https://www.centos.org/forums/viewtopic.php?f=47&t=54411
- 그들이 나에게 중요한 힌트를 주면서 다른 답변을지지
답변
이전 답변을 모두 다음 순서대로 수행해야한다는 것을 알았습니다.
sudo modprobe ipt_LOG
sudo sysctl net.netfilter.nf_log.2=ipt_LOG
그 과정에서 내가 발견 한 몇 가지가 있습니다.
다음과 같이 유효한 로거 목록 (현재 선택된 로거와 함께)을 얻을 수 있습니다.
cat /proc/net/netfilter/nf_log
여기에있는 숫자는에 정의 된 프로토콜 제품군 번호를 나타냅니다 /usr/include/bits/socket.h
. 2는 AF_INET
(IPv4), 10은 AF_INET6
(IPv6)입니다.
답변
이것은 나를 위해 일했다 sudo sysctl net.netfilter.nf_log.2=ipt_LOG