Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7757057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:59:00+00:00 2026-06-01T12:59:00+00:00

I am trying to modify the source IP of all packets outcoming from the

  • 0

I am trying to modify the source IP of all packets outcoming from the machine to something I specify in this Kernel Module, but everytime I try to access nh.iph->saddr I get an error in compile time that says Struct sk_buff has no member named nh

What am I doing wrong here?
Have I missed some header or something??

#include <linux/module.h>       
#include <linux/kernel.h>       
#include <linux/init.h>         

#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>

#include <linux/skbuff.h>
#include <linux/ip.h>                  /* For IP header */

#include <linux/inet.h> /* For in_aton(); htonl(); and other related Network utility functions */ 


static struct nf_hook_ops nfho;


unsigned int hook_func(unsigned int hooknum,
                       struct sk_buff **skb,
                       const struct net_device *in,
                       const struct net_device *out,
                       int (*okfn)(struct sk_buff *))
{
    struct sk_buff *sb = *skb;
    struct in_addr masterIP;

    masterIP.s_addr = htonl (in_aton("192.168.1.10")); 
    sb->nh.iph->saddr = masterIP.s_addr;
    return NF_ACCEPT;
}

Note that I am running Ubuntu 10.04 LTS 64 bits
Kernel 2.6.32-33

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:59:01+00:00Added an answer on June 1, 2026 at 12:59 pm

    In your kernel version the struct sk_buff has changed. It no longer has those members. To access the ip header you should try:

    #include <linux/ip.h>
    
    struct iphdr* iph = ip_hdr(skb);
    

    Then just use the iph variable to change the addresses, something like:

    iph->saddr = ....
    iph->daddr = ....
    

    Also, don’t forget that you might need to recalculate ip and possible transport packets checksums.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to change/modify the source of any/all iframe on the page where the src
This should be easy, but I'm stuck trying to modify this build.xml I'm getting
I am trying to modify an open source Forum called YetAnotherForum.net in the project
I'm trying to modify an svg tag with javascript to make it resizable, but
I am trying to modify the android lvl library and as part of this
I am trying to modify an Integer field on existing table from nullable to
I am trying to modify the code below to check the input from a
i am trying to modify one js file validation rule but unable to do
We are coming from a Visual Source Safe background and are trying to look
I'm trying to compile this code (the last one): http://www.aforgenet.com/framework/features/blobs_processing.html but it throws: Use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.