다음의 에러를 해결하려면 어떻게 해야 하나요?
kldp bbs 게시판 내용 중에서 본 Roll Your Own Firewall with Netfilter 문서를 보고 그대로 따라했는데 컴파일을 하니 다음과 같은 에러가 생깁니다.
관련에러로 구글에 검색을 해보고 나온대로 해봐도 같은 에러가 나옵니다.
어떻게 해결할 수 있을까요?
고수님들의 답변을 부탁드립니다.
참 사용하는 리눅스는 데비안 2.4.18입니다.
=================== 소스 ======================
#define __KERNEL__
#define MODULE
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
#include </usr/src/linux/include/linux/netfilter.h>
static struct nf_hook_ops netfilter_ops_in; /* NF_IP_PRE_ROUTING */
static struct nf_hook_ops netfilter_ops_out; /* NF_IP_POST_ROUTING */
/* Function prototype in <linux/netfilter> */
unsigned int main_hook(unsigned int hooknum,
struct sk_buff **skb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff*))
{
return NF_DROP; /* Drop ALL Packets */
}
int init_module()
{
netfilter_ops_in.hook = main_hook;
netfilter_ops_in.pf = PF_INET;
netfilter_ops_in.hooknum = NF_IP_PRE_ROUTING;
netfilter_ops_in.priority = NF_IP_PRI_FIRST;
netfilter_ops_out.hook = main_hook;
netfilter_ops_out.pf = PF_INET;
netfilter_ops_out.hooknum = NF_IP_POST_ROUTING;
netfilter_ops_out.priority = NF_IP_PRI_FIRST;
nf_register_hook(&netfilter_ops_in); /* register NF_IP_PRE_ROUTING hook */
nf_register_hook(&netfilter_ops_out); /* register NF_IP_POST_ROUTING hook */
return 0;
}
void cleanup()
{
nf_unregister_hook(&netfilter_ops_in); /*unregister NF_IP_PRE_ROUTING hook*/
nf_unregister_hook(&netfilter_ops_out); /*unregister NF_IP_POST_ROUTING hook*/
}
==============================================
에러내용
# gcc -c drop.c
drop.c: In function `init_module':
drop.c:26: invalid use of undefined type `struct nf_hook_ops'
drop.c:27: invalid use of undefined type `struct nf_hook_ops'
drop.c:28: invalid use of undefined type `struct nf_hook_ops'
drop.c:29: invalid use of undefined type `struct nf_hook_ops'
drop.c:31: invalid use of undefined type `struct nf_hook_ops'
drop.c:32: invalid use of undefined type `struct nf_hook_ops'
drop.c:33: invalid use of undefined type `struct nf_hook_ops'
drop.c:34: invalid use of undefined type `struct nf_hook_ops'
drop.c: At top level:
drop.c:9: storage size of `netfilter_ops_in' isn't known
drop.c:10: storage size of `netfilter_ops_out' isn't known
#
아마도
아마도 현재 컴퓨터의 구성에 netfilter가 제대로 설치가 되지 않은 것 같습니다.
만일, redhat 9을 그냥 깐정도라면 그러하겠습니다.
커널 버전
uname -a 해서 커널버전 보시고요.
******
만일 제 예상이 맞다면, 다음과 같은 작업을 수행하시기 바랍니다.
iptables.org/ 로가셔서 최신버전의 iptables-버전.tar.bz2를
받아서 설치하시고 다시 컴파일해보세요.
* 아시겠지만, 노파심에 몇자 더 적으면.(가정, 커널버전이 2.4.20-8이라고...)
iptables을 컴파일할때는 커널소스가 있어야 하고, 그 디렉터리가
명시되어야 합니다.
대충 다음과 같은 형태가 되겠지요.
그럼 1차끝.
이게 끝이 아니고, 커널을 재컴파일해주셔야 합니다.
커널옵션중 넷필터관련을 활성화시켜주시고요.
커널도 컴파일하시고 리부팅 후에 /usr/src/linux-2.4.20-8/include/linux디렉터리를
/usr/include/linux와 잘 맞춰주셔야 합니다.
해보지 않고 조언드려서(맞는지 모르겠음;전 2.6.4로 업그레이드해서
설치한 터라 :wink: ) 죄송합니다.
------------------ P.S. --------------
지식은 오픈해서 검증받아야 산지식이된다고 동네 아저씨가 그러더라.
댓글 달기