# A problem I got in setup transparent proxy mode for specific port

**URL:** <https://discourse.mitmproxy.org/t/a-problem-i-got-in-setup-transparent-proxy-mode-for-specific-port/787>\
**Category:** help\
**Created:** [January 4, 2018, 6:27am UTC](https://discourse.mitmproxy.org/t/a-problem-i-got-in-setup-transparent-proxy-mode-for-specific-port/787 "2018-01-04T06:27:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shikn](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@shikn](https://discourse.mitmproxy.org/u/shikn)\
**Post date:** [January 4, 2018, 6:27am UTC](https://discourse.mitmproxy.org/t/a-problem-i-got-in-setup-transparent-proxy-mode-for-specific-port/787/1 "2018-01-04T06:27:14Z")

</div>

I’d like to capture a HTTP service call from Host A -\> Host B to test the client on A. Both OS are Linux.  
I would like to use transparent proxy mode because I cannot modify client and cannot redirect all traffic from HostA to hostB as other service also running on HostA. I’d like only redirect the connection of the client from host A to host B.  
The client in Host A call a service on Host B on a certain port 10001 by HTTP.

I tried setup HostC with mitmproxy (HostA and HostC are in the same subnet)  
HostA (ip\_A) -\> HostC(ip\_C) with mitmproxy-\> HostB(ip\_B) , I set the ip table to build transparent mode.

Following is what I setup for on HostA

```auto
sudo iptables -t mangle -I OUTPUT -p tcp --dport 10001 -j MARK --set-mark 1
sudo ip route add default via ip_C table 100
sudo ip rule add fwmark 0x1 table 100

```

On HostC

```auto
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -t nat -A PREROUTING -o eth0 -p tcp --dport 10001 -j REDIRECT --to-port 8080
mitmproxy -T --host

```

This doesn’t work. client on HostA connection timeout.  
If I try traceroute on HostA

```auto
traceroute ip_B -p 10000 -T

```

It shows ip\_B is unreachable on TCP from HostA

What’s the recommended way to do this?

Btw. I also tried setup mitmproxy on HostA, but when I try to redirect traffic of port 10001  
on HostA

```auto
sudo iptables -t nat -A OUTPUT -p tcp --dport 10001 -j REDIRECT --to-port 8080
mitmproxy -T --host

```

The service call could be capture by mitmproxy on HostA but cannot get response.

Thanks a lot for your help.
