I have one notebook and two servers:
- ip = 172.17.0.2 (I have installed nginx here)
- ip = 172.17.0.3 (There is nothing here, but I can ping 172.17.0.2 from here)
I open browser on my notebook, open
http://172.17.0.2
and get web page from Nginx.
Now I want to do something so, if I will open
http://172.17.0.3
in the browser this server forward my request 172.17.0.2 and return me same page back.
I have connected to 172.17.0.3 and make this changes:
root@6d2de436eef0:/# sysctl net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1
root@6d2de436eef0:/# iptables -t nat -F PREROUTING
root@6d2de436eef0:/# iptables -t nat -A PREROUTING -d 172.17.0.3 -j DNAT --to-destination 172.17.0.2
root@6d2de436eef0:/# iptables -F FORWARD
root@6d2de436eef0:/# iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
root@6d2de436eef0:/# iptables -A FORWARD -m conntrack --ctstate NEW -d 172.17.0.2 -j ACCEPT
root@6d2de436eef0:/# iptables -P FORWARD DROP
Now I open
http://172.17.0.3,
but get nothing. Why and how can I fix it ?
Update
Here is a result of tcpdump on 172.17.0.3 - http://pastebin.com/47MRWqXy
Update 2
Sorry, I gave you not full information. Both servers 172.17.0.3 and 172.17.0.2 are docker containers. Here is ifconfig on the host machine:
$ ifconfig
docker0 Link encap:Ethernet HWaddr fe:69:ac:53:70:53
inet addr:172.17.42.1 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::f0ee:53ff:feae:aa6c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:162525 errors:0 dropped:0 overruns:0 frame:0
TX packets:278054 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:10471915 (10.4 MB) TX bytes:436185034 (436.1 MB)
eth0 Link encap:Ethernet HWaddr f0:de:f1:27:7a:e6
inet addr:172.20.0.136 Bcast:172.20.0.255 Mask:255.255.255.0
inet6 addr: fe80::f2de:f1ff:fe27:7ae6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:16023892 errors:0 dropped:0 overruns:0 frame:0
TX packets:4007904 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:8557520703 (8.5 GB) TX bytes:484890281 (484.8 MB)
Interrupt:20 Память:f8500000-f8520000
eth1 Link encap:Ethernet HWaddr 82:ea:96:9d:48:88
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)