I have a few fundamental conceptual issues due to which i am not able to forward the traffic on a docker container containing a network.
Docker container is listening on 2123/udp
Approach 0 Publish all argument does not seem to work. There was no mapping/change in iptables before and after this command.
docker run -d -P image
Approach 1 I want to send traffic from any interface/ip/port to a docker container. I found that most of my traffic is on eno1, ip = x.x.x.x and port 22. I tried binding this port 22 to docker using
docker run -d -p 22:2123 image As the port is active so it could not bind with port 22
Approach 2 I chose a random port 80 and tried to publish it
docker run -d -p x.x.x.x:80:2123
I did not print any error. However, when i send packets to this ip and port, connection is refused.
Packets sent as follows. dd if=/dev/zero bs=9000 count=1000 > /dev/tcp/x.x.x.x/80
Therefore i added a port forwarding rule to forward all traffic received on port 22 to x.x.x.x:80.
echo 1 > /proc/sys/net/ipv4/ip_forward iptables -t nat -A PREROUTING -p tcp --dport 22 -j DNAT --to-destination x.x.x.x:80
Still connection refused. Even with this refused connection, i saw two transactions
tcpdump -i any port 2123 IP <dockerNWip>.37042 > <host>.2123: Flags [S], seq 1289990254, win 29200, options [mss 1460,sackOK,TS val 437161 ecr 0,nop,wscale 7], length 0 IP <dockerNWip>.37042 > <host>.2123: Flags [S], seq 1289990254, win 29200, options [mss 1460,sackOK,TS val 437161 ecr 0,nop,wscale 7], length 0 IP <host>.2123 > <dockerNWip>.37042: Flags [R.], seq 0, ack 1289990255, win 0, length 0 IP <host>.2123 > <dockerNWip>.37042: Flags [R.], seq 0, ack 1, win 0, length 0
I am not sure where the problem lies. My question
1) Do i need to bind x.x.x.x and port 80? I thought the rule would do that. 2) Do i need anything else besides the publishing the ports? 3) Is my way to tcpdumping the port correct to monitor the traffic?
My strategy/assumption was that binding host port 80 with container port 2123 should automatically route the traffic.