[proof of concept] giving any docker (SABnzbd, torrents, ...) its own IP


Recommended Posts

Works at the moment with one small problem, I can not yet specify the IP address, it's an IP from the 'free' IP address range on the DHCP server.

 

Needed:

- docker-network-container : https://github.com/jeroenpeeters/docker-network-containers

- pipework : https://github.com/jpetazzo/pipework/blob/master/pipework

- dhclient

- public interface needs to be in promiscuous mode

 

This not yet automated, you need to log in the unraid server through ssh.

 

Get the needed scripts and store them somewhere on the USB drive:

# cd /boot

# mkdir Ext_ip_Docker

# cd Ext_ip_Docker

# wget https://raw.githubusercontent.com/jeroenpeeters/docker-network-containers/master/create-network-container.sh

# wget https://raw.githubusercontent.com/jeroenpeeters/docker-network-containers/master/remove-network-container.sh

# wget https://raw.githubusercontent.com/jpetazzo/pipework/master/pipework

# chmod +x create-network-container.sh remove-network-container.sh

 

Pipework needs to be installed in /opt/bin, we use a link

# cd /

# mkdir opt

# cd opt

# mkdir bin

# cd bin

# ln -s /boot/Ext_ip_Docker/pipework

# chmod +x /opt/bin/pipework

 

Dhclient is needed by these scripts, we have on slackware only dhcpcd

# ln -s /sbin/dhcpcd /sbin/dhclient

 

Check if our external facing interface is in promiscuous mode

# ifconfig

>br0: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST>  mtu 1500

>        inet 10.87.51.78  netmask 255.255.255.0  broadcast 10.87.51.255

>        ether 0c:c4:7a:05:46:5e  txqueuelen 0  (Ethernet)

>        RX packets 1970040  bytes 181818101 (173.3 MiB)

>        RX errors 0  dropped 4099  overruns 0  frame 0

>        TX packets 4386356  bytes 462429946 (441.0 MiB)

>        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

(br0: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST>  mtu 1500) needs to contain PROMISC,  if not do a

# ip link set dev br0 promisc on

 

br0 is the correct interface because it has the IP address we use to connect to the server (in my case 10.87.51.78)

 

Now we need the name of the container that needs its own IP, in my case a SABnzbd container

# docker ps

>CONTAINER ID        IMAGE                  COMMAND            CREATED            STATUS              PORTS                    NAMES

>36665c5a45b6        needo/sabnzbd:latest  "/sbin/my_init"    3 weeks ago        Up 12 minutes      0.0.0.0:8080->8080/tcp  SABnzbd

 

Name = SABnzbd ; interface = br0 : lets create the network container

# /boot/Ext_ip_Docker/create-network-container.sh  SABnzbd br0

>creating iptables route for port 8080

>Unable to find image 'jeroenpeeters/public-networking:latest' locally

>Pulling repository jeroenpeeters/public-networking

>cb60650ca7e4: Pulling image (latest) from jeroenpeeters/public-networking

>cb60650ca7e4: Pulling image (latest) from jeroenpeeters/public-networking, endpoint: https://registry-1.docker.io/v1/

>cb60650ca7e4: Pulling dependent layers

>511136ea3c5a: Download complete

>5b12ef8fd570: Pulling metadata

>5b12ef8fd570: Pulling fs layer

>5b12ef8fd570: Download complete

>f6808a3e4d9e: Pulling metadata

>f6808a3e4d9e: Pulling fs layer

>f6808a3e4d9e: Download complete

>99f259716c33: Pulling metadata

>99f259716c33: Pulling fs layer

>99f259716c33: Download complete

>6059fe46b83e: Pulling metadata

>6059fe46b83e: Pulling fs layer

>6059fe46b83e: Download complete

>cb60650ca7e4: Pulling metadata

>cb60650ca7e4: Pulling fs layer

>cb60650ca7e4: Download complete

>cb60650ca7e4: Download complete

>Status: Downloaded newer image for jeroenpeeters/public-networking:latest

>containerid=5a5ae232229c7bc009ff9e4b3df1a44c924dede45240857f860517ad4cf7ae82

>waiting on IP from DHCP

>waiting on IP from DHCP

>waiting on IP from DHCP

>waiting on IP from DHCP

>waiting on IP from DHCP

>waiting on IP from DHCP

>waiting on IP from DHCP

>waiting on IP from DHCP

>waiting on IP from DHCP

>waiting on IP from DHCP

>ip=10.87.51.29

 

SUCCESS!!!!

 

#  docker ps

>CONTAINER ID        IMAGE                                                        COMMAND                    CREATED              STATUS                  PORTS                              NAMES

>5a5ae232229c        jeroenpeeters/public-networking:latest  "bash /scripts/71261  5 minutes ago      Up 5 minutes                                                  publicnetwork-SABnzbd

>36665c5a45b6        needo/sabnzbd:latest                              "/sbin/my_init"            3 weeks ago        Up 22 minutes      0.0.0.0:8080->8080/tcp  SABnzbd

 

I can now access the SABnzbd server through 10.87.51.29:8080 instead of 10.87.51.78:8080

 

 

To specify the IP address, the create-network-container.sh script needs to be modified so that the DHCP server gets a MAC address from the container. I'll give it a try, but my script skills are limited. I also contacted the script writer if he would update the script so we can specify a fixed IP. To be continued...

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.