Fully transparent proxy mode
Clash 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:
debian networking iptables routing proxy
add a comment |Â
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:
debian networking iptables routing proxy
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
add a comment |Â
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:
debian networking iptables routing proxy
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:
debian networking iptables routing proxy
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
add a comment |Â
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
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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