Change the default docker0 interface address

I was deploying Zenoss core 5, as you may know, zenoss core 5 is packed into a docker container. so the deployment is to get the docker installed, then install the Zenoss Control Center, then download the proper docker image. To me, while it simplifies the deployment of Zenoss Core 5 itself and ease the backup/restore, it actually introduce some overheads to manage the system.

One of the issues I met was on default docker0 interface, by default, the interface has an IP address: 172.17.42.1, but I have a few subnets which are in 172.17 range, so I had some trouble to reach those devices because of default routing. So I have to change the default address.

Steps to change the docker0 interface address:

I run Zenoss on CentOS 7, so the steps here only cover CentOS.

1. Stop Serviced ( control center process )

systemctl stop serviced

2. Stop docker

systemctl stop docker

3. change the file /etc/sysconfig/docker

default: DOCKER_OPTS=”-s btrfs –dns=172.17.42.1″

change to: DOCKER_OPTS=”-s btrfs –bip=192.168.10.254/24″

192.168.10.254 is an example here, you need to pick up the range suits your environment.

4. run the command below :

ip link set dev docker0 down

brctl delbr docker0

iptables -t nat -F POSTROUTING ( flush the nat table is very important, you may still have the old entries which was using the default 172.17 range, which will cause network issues )

5. bring up the docker service and the new address should be assigned to docker0

systemctl start docker

6. You might want to inject another rule into iptables to allow the docker0 and other virutal interfaces to be able to communicate with external world.

iptables -A INPUT -d 192,168.10.0/24 -j ACCEPT

If you still have trouble, you need to check carefully of your iptables, local policy routing etc.

You can also check the docker advanced network here:

https://docs.docker.com/articles/networking/#customizing-docker0


		
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s