Sponsored Content
Operating Systems Linux Docker and pipework,ip with other subnet Post 302948323 by Linusolaradm1 on Monday 29th of June 2015 06:40:43 PM
Old 06-29-2015
Docker and pipework,ip with other subnet

Recently i found this for give to docker a "personal" ip

Code:
    ip addr del 10.1.1.133/24 dev eth0
    ip link add link eth0 dev eth0m type macvlan mode bridge
    ip link set eth0m up
    ip addr add 10.1.1.133/24 dev eth0m
    route add default gw 10.1.1.1

On container i did

Code:
    CID=$(docker run -d ...)
    pipework eth0 $CID 10.1.1.133/24@10.1.1.1

This works fine if host and docker containers all are on same subnet(10.1.1.0/24 in this case)
But if i want to use a different subnet for dockers?
For example 10.2.2.0/24?

I have tried a iptables masquerade,but nothing works,the docker container cannot ping or reach external network(internet).


Code:
    iptables -t nat -A POSTROUTING -m iprange --src-range 10.2.2.2-10.2.2.255 -o eth0 -j MASQUERADE

Of course ip forwarding is enabled

---------- Post updated 29-06-15 at 05:40 PM ---------- Previous update was 28-06-15 at 10:02 PM ----------

Solution found.
The host must setup as router,enable iptables NAT and enable route to new ip class,in this case eth0m is the bridged network

Code:
    iptables -A FORWARD -i eth0m -o eth0m -j ACCEPT
    iptables -A FORWARD -i eth0m -o eth0m  -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
    iptables -t nat  -A POSTROUTING -o eth0m -j MASQUERADE

pipework must use the new router,in this case is 192.168.0.254

Code:
    pipework eth0 $DOCKID 10.8.3.1/24@192.168.0.254

and finally route must be added,in this case 10.8.3.0 is the other ip class

Code:
    route add -net 10.8.3.0 netmask 255.255.255.0  dev eth0m


Last edited by Linusolaradm1; 06-29-2015 at 07:51 PM..
 

9 More Discussions You Might Find Interesting

1. IP Networking

Subnet mask

Hi, I have about 30 computers for users with subnet mask x.x.x.0, and 25 computers for workers with s.m. x.x.x.128. My server has a s.m. x.x.x.128 so with workers computers I can see my server and all the computers in that s.m., but I can't see the server from the users computers and I need to see... (7 Replies)
Discussion started by: Z0DiaC
7 Replies

2. UNIX for Advanced & Expert Users

Two Ethernet Connections to Same Subnet

Hi Gurus, I have a Sun Box ( Sun OS 5.5.1 ) running with two Fast Ethernet PCI cards ( instance hme1 and hme2 ), apart from the onboard Ethernet connection. These two Ethernets are connected to the same subnet. Now, will there be any automated load balancing due to these two Ethernet... (1 Reply)
Discussion started by: shibz
1 Replies

3. IP Networking

Migrating existing Subnet to a new subnet and changing ip addresses in UNIX

Hi, My project needs to migrate the existing Subnet (255.255.255.0) to a new subnet and change the ipaddresses (currently C class). How can I do that. I need some information. John (0 Replies)
Discussion started by: johnmarsh
0 Replies

4. IP Networking

How do I figure out the subnet?

Hi, How do I get subnet from this: 10.252.0.138/25 Tnx (2 Replies)
Discussion started by: mehrdad68
2 Replies

5. IP Networking

How many hosts per subnet

What would be a realistic number of hosts in a 100BaseT network, before you have to start thinking on subnetting further? Or in another words. How many hosts would you keep in the same broadcast domain? In a 100BaseT network, with subnet 10.20.20.0/24, I could have 254 hosts as part of the same... (3 Replies)
Discussion started by: Aia
3 Replies

6. IP Networking

2 ip from one subnet my isp

Hi. my english is not so good. sorry. i have some problem. My isp give me second ip from subnet. One network is working, but secong don't. fxp0 - my network dc0 - network isp (that working) re0 - network isp (don't working) i try use ng_one2many, but it's don't working ngctl mkpeer... (0 Replies)
Discussion started by: kil
0 Replies

7. Shell Programming and Scripting

Problem in extracting yocto SDK for docker

Actually I was facing the following issue while building my Yocto SDK on Docker container sudo docker build --tag="akash/eclipse-che:6.5.0-1" --tag="akash/eclipse-che:latest" /home/akash/dockerimage.yocto.support/ Sending build context to Docker daemon 26.93MB Step 1/5 : FROM eclipse/cpp_gcc ... (3 Replies)
Discussion started by: Akash BHardwaj
3 Replies

8. UNIX for Beginners Questions & Answers

Can't pass a variable representing the output of lsb_release to a docker dontainer

I don't know why, but the rendering of my code mucks up the spacing and indentation, despite being correct in the original file. I'm having issues getting the following script to run (specifically the nested script at the end of the docker command near the end of the script; I think I'm not passing... (2 Replies)
Discussion started by: James Ray
2 Replies

9. Docker

Docker learning Phase-I

Hello All, I had recently learnt a bit of Docker(which provides containerization process). Here are some of my learning points from it. Let us start first with very basic question: What is Docker: Docker is a platform for sysadmins and developers to DEPLOY, DEVELOP and RUN applications ... (7 Replies)
Discussion started by: RavinderSingh13
7 Replies
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 11:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy