From: JC <bikkit@gmail.com>
To: netfilter-devel@lists.netfilter.org, netfilter@lists.netfilter.org
Subject: How to change the source address of a tcp packet
Date: Wed, 21 Sep 2005 06:04:33 +0100 [thread overview]
Message-ID: <a60102c305092022044e76b204@mail.gmail.com> (raw)
netfilter hook function called at NF_IP_PRE_ROUTING:
unsigned int in_hook(unsigned int hooknum,
struct sk_buff **skb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff *))
{
struct iphdr *my_ipheader;
struct tcphdr *my_tcpheader;
struct udphdr *my_udpheader;
unsigned char *my_ip1;
unsigned char *my_ip2;
unsigned char *my_ip3;
unsigned char *my_ip4;
my_ip1 = "SOMETHING_IN_HEX"; //
my_ip2 = "SOMETHING_IN_HEX"; //
my_ip3 = "SOMETHING_IN_HEX"; //
my_ip4 = "SOMETHING_IN_HEX"; //
if (out)
{
if(out->name)
{
// We do NOT want to handle a "weird" null packet
if(skb == NULL)
{
print_string("NULL skb!!!");
return NF_ACCEPT;
}
my_ipheader = (struct iphdr*)((*skb)->nh.iph);
if (my_ipheader->protocol == IPPROTO_TCP)
{
print_string("This is a tcp packet");
if (my_ipheader->saddr == *(unsigned int *)my_ip3)
{
print_string("with source IP xxx.xxx.xxx.xxx");
((struct iphdr*)((*skb)->nh.iph))->saddr = my_ip2;
((struct sk_buff*)(*skb))->proto_csum_blank = 1;
return NF_ACCEPT;
}
}
}
else
{
print_string("out is null");
}
}
print_string("packet is being accepted!");
return NF_ACCEPT;
}
Apparently, these two steps are not sufficient to change the source
address of an skb:
((struct iphdr*)((*skb)->nh.iph))->saddr = my_ip2;
((struct sk_buff*)(*skb))->proto_csum_blank = 1;
All packets that are treated by these are actually dropped.
What *IS* required so that the source address of the skb is changed to
another that is on another interface of the machine?
J
reply other threads:[~2005-09-21 5:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a60102c305092022044e76b204@mail.gmail.com \
--to=bikkit@gmail.com \
--cc=netfilter-devel@lists.netfilter.org \
--cc=netfilter@lists.netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox