# Accessing local network from Docker container

**URL:** <https://forums.docker.com/t/accessing-local-network-from-docker-container/48062>\
**Category:** General\
**Tags:** docker\
**Created:** [March 18, 2018, 3:35pm UTC](https://forums.docker.com/t/accessing-local-network-from-docker-container/48062 "2018-03-18T15:35:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jansu](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/jansu/32/19261_2.png) [@jansu](https://forums.docker.com/u/jansu)\
**Post date:** [March 18, 2018, 3:35pm UTC](https://forums.docker.com/t/accessing-local-network-from-docker-container/48062/1 "2018-03-18T15:35:31Z")

</div>

Hello!

I’m setting up `nginx:alpine`as reverse proxy and would like to expose some locally available websites to the outer world. Those sites are hosted on different computers in local network `192.168.254.0/24`, for example:

- `192.168.254.49`
- `192.168.254.50`
- `192.168.254.51`

Because I wouldn’t like transfer all configurations and files from those computers to my main machine where I’m setting up nginx Docker container, I decided to create proxy. However the problem here is that when I setup nginx with proxy config, before mentioned IPs are not accessible from container (logs are showing that IPs are not accessable & ping is not responding either). I was looking how to do that with bridges and Docker networks, but couldn’t figure it out yet.

Basically the question is - what do I have to do to access my local network `192.168.254.0/24` from Docker container (currently in default bridged network `172.17.0.0/24`)?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![dmaze](https://avatars.discourse-cdn.com/v4/letter/d/ea5d25/32.png) [@dmaze](https://forums.docker.com/u/dmaze)\
**Post date:** [March 18, 2018, 4:28pm UTC](https://forums.docker.com/t/accessing-local-network-from-docker-container/48062/2 "2018-03-18T16:28:25Z")

</div>

> [@jansu](#):
>
> Basically the question is - what do I have to do to access my local network `192.168.254.0/24` from Docker container (currently in default bridged network `172.17.0.0/24`)?

You shouldn’t have to do anything. What’s the host’s IP address? (Is it on the 192.168.254.0/24 network?) Have you tried setting up anything special with Docker, or are you using the totally default network setup? Do you need any special routing to reach that network? Any funky firewalling or routing setups?

(In the setup you describe, if the host is say 192.168.254.2, and you did something like

```auto
docker run --rm busybox wget -O- http://192.168.254.49/

```

I’d expect it to work.)

---

<div class="post-metadata">

**Author:** ![jansu](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/jansu/32/19261_2.png) [@jansu](https://forums.docker.com/u/jansu)\
**Post date:** [March 18, 2018, 4:43pm UTC](https://forums.docker.com/t/accessing-local-network-from-docker-container/48062/3 "2018-03-18T16:43:16Z")

</div>

Host is Debian 9 and in the same network with IP `192.168.254.100`. There is no any special configuration, I installed Docker as written in documentation (also didn’t add any volume/network/…) . Same for router - host can normally access `192.168.254.49` and other computers.

I tried with …

```auto
docker run --rm busybox wget -O- http://192.168.254.49/

```

… but I get …

```auto
wget: can't connect to remote host (192.168.254.49): Connection timed out

```

… after some time.

I’ve tried the same with some other images and the problem persists. However on the other machine with Windows 10 the local network is normally accessible from any container. Will try to establish Docker on other distribution and check if there is something wrong with my current installation.

---

<div class="post-metadata">

**Author:** ![jansu](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/jansu/32/19261_2.png) [@jansu](https://forums.docker.com/u/jansu)\
**Post date:** [March 18, 2018, 8:32pm UTC](https://forums.docker.com/t/accessing-local-network-from-docker-container/48062/4 "2018-03-18T20:32:54Z")

</div>

Figured out what was causing this problem - I forgot that I added service file for Docker and disabled its managing of `iptables`. In that case [this thread](https://github.com/moby/moby/issues/4737) explains what’s needed to establish communication between host/LAN and container. For my current needs I used this command:

```auto
iptables -t nat -A POSTROUTING ! -o docker0 -s 172.17.0.0/16 -j MASQUERADE

```

Thanks for help anyway!
