# Static IP not working

**URL:** <https://forums.docker.com/t/static-ip-not-working/40399>\
**Category:** General\
**Created:** [October 26, 2017, 7:59pm UTC](https://forums.docker.com/t/static-ip-not-working/40399 "2017-10-26T19:59:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![logicethos](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/logicethos/32/17684_2.png) [@logicethos](https://forums.docker.com/u/logicethos)\
**Post date:** [October 26, 2017, 7:59pm UTC](https://forums.docker.com/t/static-ip-not-working/40399/1 "2017-10-26T19:59:05Z")

</div>

My ISP has given me a 10 IP addresses. x.x.x.91-95 and x.x.x.161-165  
I want to use 9 of them for my containers.

I have the host eth0 on x.x.x.91

So I did:  
`docker network create --subnet x.x.x.0/24 --gateway x.x.x.254 mynet`

and then

`docker run -it --net mynet --ip x.x.x.165 ubuntu /bin/bash`

But I can’t connect out. Inside a container:

```
PING 8.8.8.8 (8.8.8.8): 56 data bytes
3 packets transmitted, 0 packets received, 100% packet loss

# ifconfig 
eth0 Link encap:Ethernet HWaddr 02:42:5b:cc:d2:a5  
          inet addr:x.x.x.165 Bcast:0.0.0.0 Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:16 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1296 (1.2 KB) TX bytes:504 (504.0 B)

# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 x.x.x.254 0.0.0.0 UG 0 0 0 eth0
x.x.x.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

```

Any ideas?  
Docker version 17.09.0-ce, build afdb6d4

---

<div class="post-metadata">

**Author:** ![logicethos](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/logicethos/32/17684_2.png) [@logicethos](https://forums.docker.com/u/logicethos)\
**Post date:** [October 27, 2017, 1:03am UTC](https://forums.docker.com/t/static-ip-not-working/40399/2 "2017-10-27T01:03:14Z")

</div>

It seems to be a problem with the IP address that is assigned to the bridge docker creates.

```
br-99d73cc121b0 Link encap:Ethernet HWaddr 02:42:ef:2f:b5:22  
inet addr:x.x.x.1 Bcast:0.0.0.0 Mask:255.255.255.0

```

x.x.x.1 doesn’t exist.

I have been playing around with setting the --bip setting, to create a custom docker0 with some success. But then I cant use the --IP setting on a container, as it says it’s not a user defined network.

---

<div class="post-metadata">

**Author:** ![logicethos](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/logicethos/32/17684_2.png) [@logicethos](https://forums.docker.com/u/logicethos)\
**Post date:** [October 27, 2017, 6:42am UTC](https://forums.docker.com/t/static-ip-not-working/40399/3 "2017-10-27T06:42:28Z")

</div>

Solved.

I switched to the Macvlan driver

> **[Get started with Macvlan network driver](https://docs.docker.com/engine/userguide/networking/get-started-macvlan/)**
>
> Libnetwork gives users total control over both IPv4 and IPv6 addressing. The VLAN drivers build on top of that in giving operators complete control of layer 2 VLAN tagging for...

---

<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:** [October 27, 2017, 10:46am UTC](https://forums.docker.com/t/static-ip-not-working/40399/4 "2017-10-27T10:46:21Z")

</div>

> [@logicethos](#):
>
> My ISP has given me a 10 IP addresses. x.x.x.91-95 and x.x.x.161-165  
> I want to use 9 of them for my containers.

If I were doing this, I’d assign all 10 addresses to the host, and `docker run -p` has a field to say which specific address a container is bound to. I’d otherwise use the default networking and the normal network driver. Something like:

```auto
sudo ip addr add x.x.x.92 dev eth0
sudo docker run -p x.x.x.92:80:8000 -d ...

```
