All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Humberto Jucá" <betolj@gmail.com>
To: Glen Huang <heyhgl@gmail.com>, netfilter@vger.kernel.org
Subject: Re: How to trace IPSec packets?
Date: Mon, 29 Jan 2018 09:25:42 -0300	[thread overview]
Message-ID: <CACuyg267+379fHkBactPOShqsrXzQWxq4TM6ZBFh=WJZvqN0vQ@mail.gmail.com> (raw)
In-Reply-To: <CALNXhk0TefWZQ7_e+JOuDL7Qs7KFq2DwQ4h+CayKHd3uWd_y_Q@mail.gmail.com>

Hi Glen Huang,


> I have an IPSec tunnel set up between my machine and a server.

- check you source routing address with this command:
ip route get 8.8.8.8

"So, replace your source address to *src ip address*"


> But after dig @8.8.8.8 google.com on my machine, running grep 'TRACE:' /var/log/kern.log on the server returned nothing.

- after this, you need rewrite your firewall rules in a OUTPUT chain:
iptables -t nat -I OUTPUT -s $SRC_ADDRESS -d 8.8.8.8 -p udp
--dport 53 -j DNAT --to-destination 127.0.0.1

"Because you are redirecting your internal traffic, use OUTPUT chain."

2018-01-29 7:07 GMT-03:00 Glen Huang <heyhgl@gmail.com>:
> (Previous message seems to get smudged. This is a resent.)
>
> Hi,
>
> Hope the question isn’t too basic to be asked here.
>
> I have an IPSec tunnel set up between my machine and a server. All
> packets originate from my machine go through that tunnel and then get
> forwarded by the server. I’m trying to redirect DNS request from my
> machine to 8.8.8.8 to a dns forwarder running on the server.
>
> I tried this on the server
>
> iptables -t nat -I PREROUTING -s $IPSEC_VIRTUAL_IP -d 8.8.8.8 -p udp
> --dport 53 -j DNAT --to-destination 127.0.0.1
>
> But it didn't work. To make sure it wasn't because I hadn't allowed
> martian packets or anything. I tried to trace the decrypted packets.
>
> iptables -t raw -I PREROUTING -s $IPSEC_VIRTUAL_IP -d 8.8.8.8 -p udp
> --dport 53 -j TRACE
>
> But after dig @8.8.8.8 google.com on my machine, running grep 'TRACE:'
> /var/log/kern.log on the server returned nothing.
>
> According to this picture:
> https://en.wikipedia.org/wiki/Iptables#/media/File:Netfilter-packet-flow.svg
> after decrypting the ipsec packets, netfilter will make the decrypted
> packets go through the ip stack again, and the trace target should be
> able to catch it.
>
> I wonder if my mental model is incorrect or I missed something?
>
> Regards,
> Glen
>
> On Mon, Jan 29, 2018 at 5:10 PM, Glen Huang <heyhgl@gmail.com> wrote:
>> Hi,
>>
>> Hope the question isn’t too basic to be asked here.
>>
>> I have an IPSec tunnel set up between my machine and a server. All packets originate from my machine go through that tunnel and then get forwarded by the server. I’m trying to redirect DNS request from my machine to 8.8.8.8 to a dns forwarder running on the server.
>>
>> I tried this on the server
>>
>> iptables -t nat -I PREROUTING -s $IPSEC_VIRTUAL_IP -d 8.8.8.8 -p udp --dport 53 -j DNAT --to-destination 127.0.0.1
>>
>> But it didn't work. To make sure it wasn't because I hadn't allowed martian packets or anything. I tried to trace the decrypted packets.
>>
>> iptables -t raw -I PREROUTING -s $IPSEC_VIRTUAL_IP -d 8.8.8.8 -p udp --dport 53 -j TRACE
>>
>> But after dig @8.8.8.8 google.com on my machine, running grep 'TRACE:' /var/log/kern.log on the server returned nothing.
>>
>> According to this picture: https://en.wikipedia.org/wiki/Iptables#/media/File:Netfilter-packet-flow.svg after decrypting the ipsec packets, netfilter will make the decrypted packets go through the ip stack again, and the trace target should be able to catch it.
>>
>> I wonder if my mental model is incorrect or I missed something?
>>
>> Regards,
>> Glen
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2018-01-29 12:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-29  9:10 How to trace IPSec packets? Glen Huang
2018-01-29 10:07 ` Glen Huang
2018-01-29 12:25   ` Humberto Jucá [this message]
2018-01-29 13:12     ` Glen Huang
     [not found]       ` <CAP9CGviN_ZsMVq2M_bFvd8gkHFgF_uw-Qqb1fkokeVDALMhc7w@mail.gmail.com>
2018-01-29 15:09         ` Glen Huang
     [not found]           ` <CAP9CGvjOSrYCYNGTD2fScBac-vLG51BwcyfE5u=eKxsai625WQ@mail.gmail.com>
     [not found]             ` <CAP9CGvhH78bAfeG_RZn_kLfFzik23ETrccrGSpQxu=H2wLcpug@mail.gmail.com>
2018-01-30  4:16               ` Glen Huang
2018-01-30 18:41                 ` Jeff Kletsky
2018-01-31  4:55                   ` Glen Huang
2018-02-01 12:21                     ` Raymond Burkholder

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='CACuyg267+379fHkBactPOShqsrXzQWxq4TM6ZBFh=WJZvqN0vQ@mail.gmail.com' \
    --to=betolj@gmail.com \
    --cc=heyhgl@gmail.com \
    --cc=netfilter@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.