Fully transparent proxy mode

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












By default mitmproxy will use its own local IP address for its server-side connections. What I want instead is mitmproxy to use the client’s IP address for server-side connections.



The following config is supplied to make this work:



CLIENT_NET=192.168.1.0/24
TABLE_ID=100
MARK=1

echo "$TABLE_ID mitmproxy" >> /etc/iproute2/rt_tables
iptables -t mangle -A PREROUTING -d $CLIENT_NET -j MARK --set-mark $MARK
iptables -t nat
-A PREROUTING -p tcp -s $CLIENT_NET
--match multiport --dports 80,443 -j
REDIRECT --to-port 8080

ip rule add fwmark $MARK lookup $TABLE_ID
ip route add local $CLIENT_NET dev lo table $TABLE_ID


Mitmproxy is listening on the router (192.168.178.40) on port: 8080



However my setup consists of a custom debian router with 2 NICs.



  • One internet facing wlp2s0 (also used to SSH into it) with address: 192.168.178.40

  • One NIC set as default gateway enp4s0 for the target client at: 10.0.0.1

The client connects to the default gateway with address 10.0.0.12



By default I use the following IP table rules to redirect my client traffic to port 8080:



sudo iptables -t nat -A PREROUTING -i enp4s0 -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo iptables -t nat -A PREROUTING -i enp4s0 -p tcp --dport 443 -j REDIRECT --to-port 8008


While this works as intended, I'd like to be able to spoof the client source address so that the HTTP(S) requests captured match the TCP packets and other traffic also coming from the client.



Here's a picture to visualize my setup because I am pretty horrible at explaining:



Transparent proxy setup.







share|improve this question




















  • I'm a bit confused about what you're asking. There's effectively three machines in this: 1 The client machine, 2 the proxy / router, 3 the web-server on the internet. Which of these do you want to see a different IP to the one it already is?
    – couling
    Mar 7 at 12:26










  • @couling : he (also) wants machine 3 to see machine 1's IP, not machine 2's IP . There's no NAT done by machine 2 between machine 1 and 3, so that makes sense to want this.
    – A.B
    Mar 8 at 19:10










  • @A.B That's what I suspected but its a bit unclear and if that is what the OP wants then it's several orders of magnitude more complicated than it might look. Not to mention an unusual requirement.
    – couling
    Mar 8 at 20:07















up vote
0
down vote

favorite












By default mitmproxy will use its own local IP address for its server-side connections. What I want instead is mitmproxy to use the client’s IP address for server-side connections.



The following config is supplied to make this work:



CLIENT_NET=192.168.1.0/24
TABLE_ID=100
MARK=1

echo "$TABLE_ID mitmproxy" >> /etc/iproute2/rt_tables
iptables -t mangle -A PREROUTING -d $CLIENT_NET -j MARK --set-mark $MARK
iptables -t nat
-A PREROUTING -p tcp -s $CLIENT_NET
--match multiport --dports 80,443 -j
REDIRECT --to-port 8080

ip rule add fwmark $MARK lookup $TABLE_ID
ip route add local $CLIENT_NET dev lo table $TABLE_ID


Mitmproxy is listening on the router (192.168.178.40) on port: 8080



However my setup consists of a custom debian router with 2 NICs.



  • One internet facing wlp2s0 (also used to SSH into it) with address: 192.168.178.40

  • One NIC set as default gateway enp4s0 for the target client at: 10.0.0.1

The client connects to the default gateway with address 10.0.0.12



By default I use the following IP table rules to redirect my client traffic to port 8080:



sudo iptables -t nat -A PREROUTING -i enp4s0 -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo iptables -t nat -A PREROUTING -i enp4s0 -p tcp --dport 443 -j REDIRECT --to-port 8008


While this works as intended, I'd like to be able to spoof the client source address so that the HTTP(S) requests captured match the TCP packets and other traffic also coming from the client.



Here's a picture to visualize my setup because I am pretty horrible at explaining:



Transparent proxy setup.







share|improve this question




















  • I'm a bit confused about what you're asking. There's effectively three machines in this: 1 The client machine, 2 the proxy / router, 3 the web-server on the internet. Which of these do you want to see a different IP to the one it already is?
    – couling
    Mar 7 at 12:26










  • @couling : he (also) wants machine 3 to see machine 1's IP, not machine 2's IP . There's no NAT done by machine 2 between machine 1 and 3, so that makes sense to want this.
    – A.B
    Mar 8 at 19:10










  • @A.B That's what I suspected but its a bit unclear and if that is what the OP wants then it's several orders of magnitude more complicated than it might look. Not to mention an unusual requirement.
    – couling
    Mar 8 at 20:07













up vote
0
down vote

favorite









up vote
0
down vote

favorite











By default mitmproxy will use its own local IP address for its server-side connections. What I want instead is mitmproxy to use the client’s IP address for server-side connections.



The following config is supplied to make this work:



CLIENT_NET=192.168.1.0/24
TABLE_ID=100
MARK=1

echo "$TABLE_ID mitmproxy" >> /etc/iproute2/rt_tables
iptables -t mangle -A PREROUTING -d $CLIENT_NET -j MARK --set-mark $MARK
iptables -t nat
-A PREROUTING -p tcp -s $CLIENT_NET
--match multiport --dports 80,443 -j
REDIRECT --to-port 8080

ip rule add fwmark $MARK lookup $TABLE_ID
ip route add local $CLIENT_NET dev lo table $TABLE_ID


Mitmproxy is listening on the router (192.168.178.40) on port: 8080



However my setup consists of a custom debian router with 2 NICs.



  • One internet facing wlp2s0 (also used to SSH into it) with address: 192.168.178.40

  • One NIC set as default gateway enp4s0 for the target client at: 10.0.0.1

The client connects to the default gateway with address 10.0.0.12



By default I use the following IP table rules to redirect my client traffic to port 8080:



sudo iptables -t nat -A PREROUTING -i enp4s0 -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo iptables -t nat -A PREROUTING -i enp4s0 -p tcp --dport 443 -j REDIRECT --to-port 8008


While this works as intended, I'd like to be able to spoof the client source address so that the HTTP(S) requests captured match the TCP packets and other traffic also coming from the client.



Here's a picture to visualize my setup because I am pretty horrible at explaining:



Transparent proxy setup.







share|improve this question












By default mitmproxy will use its own local IP address for its server-side connections. What I want instead is mitmproxy to use the client’s IP address for server-side connections.



The following config is supplied to make this work:



CLIENT_NET=192.168.1.0/24
TABLE_ID=100
MARK=1

echo "$TABLE_ID mitmproxy" >> /etc/iproute2/rt_tables
iptables -t mangle -A PREROUTING -d $CLIENT_NET -j MARK --set-mark $MARK
iptables -t nat
-A PREROUTING -p tcp -s $CLIENT_NET
--match multiport --dports 80,443 -j
REDIRECT --to-port 8080

ip rule add fwmark $MARK lookup $TABLE_ID
ip route add local $CLIENT_NET dev lo table $TABLE_ID


Mitmproxy is listening on the router (192.168.178.40) on port: 8080



However my setup consists of a custom debian router with 2 NICs.



  • One internet facing wlp2s0 (also used to SSH into it) with address: 192.168.178.40

  • One NIC set as default gateway enp4s0 for the target client at: 10.0.0.1

The client connects to the default gateway with address 10.0.0.12



By default I use the following IP table rules to redirect my client traffic to port 8080:



sudo iptables -t nat -A PREROUTING -i enp4s0 -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo iptables -t nat -A PREROUTING -i enp4s0 -p tcp --dport 443 -j REDIRECT --to-port 8008


While this works as intended, I'd like to be able to spoof the client source address so that the HTTP(S) requests captured match the TCP packets and other traffic also coming from the client.



Here's a picture to visualize my setup because I am pretty horrible at explaining:



Transparent proxy setup.









share|improve this question











share|improve this question




share|improve this question










asked Mar 7 at 8:46









user329538

1




1











  • I'm a bit confused about what you're asking. There's effectively three machines in this: 1 The client machine, 2 the proxy / router, 3 the web-server on the internet. Which of these do you want to see a different IP to the one it already is?
    – couling
    Mar 7 at 12:26










  • @couling : he (also) wants machine 3 to see machine 1's IP, not machine 2's IP . There's no NAT done by machine 2 between machine 1 and 3, so that makes sense to want this.
    – A.B
    Mar 8 at 19:10










  • @A.B That's what I suspected but its a bit unclear and if that is what the OP wants then it's several orders of magnitude more complicated than it might look. Not to mention an unusual requirement.
    – couling
    Mar 8 at 20:07

















  • I'm a bit confused about what you're asking. There's effectively three machines in this: 1 The client machine, 2 the proxy / router, 3 the web-server on the internet. Which of these do you want to see a different IP to the one it already is?
    – couling
    Mar 7 at 12:26










  • @couling : he (also) wants machine 3 to see machine 1's IP, not machine 2's IP . There's no NAT done by machine 2 between machine 1 and 3, so that makes sense to want this.
    – A.B
    Mar 8 at 19:10










  • @A.B That's what I suspected but its a bit unclear and if that is what the OP wants then it's several orders of magnitude more complicated than it might look. Not to mention an unusual requirement.
    – couling
    Mar 8 at 20:07
















I'm a bit confused about what you're asking. There's effectively three machines in this: 1 The client machine, 2 the proxy / router, 3 the web-server on the internet. Which of these do you want to see a different IP to the one it already is?
– couling
Mar 7 at 12:26




I'm a bit confused about what you're asking. There's effectively three machines in this: 1 The client machine, 2 the proxy / router, 3 the web-server on the internet. Which of these do you want to see a different IP to the one it already is?
– couling
Mar 7 at 12:26












@couling : he (also) wants machine 3 to see machine 1's IP, not machine 2's IP . There's no NAT done by machine 2 between machine 1 and 3, so that makes sense to want this.
– A.B
Mar 8 at 19:10




@couling : he (also) wants machine 3 to see machine 1's IP, not machine 2's IP . There's no NAT done by machine 2 between machine 1 and 3, so that makes sense to want this.
– A.B
Mar 8 at 19:10












@A.B That's what I suspected but its a bit unclear and if that is what the OP wants then it's several orders of magnitude more complicated than it might look. Not to mention an unusual requirement.
– couling
Mar 8 at 20:07





@A.B That's what I suspected but its a bit unclear and if that is what the OP wants then it's several orders of magnitude more complicated than it might look. Not to mention an unusual requirement.
– couling
Mar 8 at 20:07
















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f428692%2ffully-transparent-proxy-mode%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f428692%2ffully-transparent-proxy-mode%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay