• 14
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

I'm trying to create a Docker macvlan interface to assign a public IP to a container and allow it to access the internet directly, using bellow command

docker network create -d macvlan --subnet=212.xx.xxx.xxx/32 --gateway=62.210.0.1  -o parent=eno1 my-macvlan-net

but I'm getting bellow error

no matching subnet for gateway 62.210.0.1

The problem is, i'm using a server from a provider, and they provide a single gateway to all servers "62.210.0.1", which is not on the same subnet of the server, using virtualbox or vmware it works without any problem using bellow interfaces file (debian vm):

auto eth0
iface eth0 inet static
        address 212.xx.xxx.xxx
        netmask 255.255.255.255
        pointopoint 62.210.0.1
        gateway 62.210.0.1

I searched the internet thorougly and couldn't find a solution, I don't want to use a loadbalancer or a reverse proxy ...etc, is there a way to force Docker to create a network with this config?!!

For now it can probably only be done manually with ip:

[tom@archlinux ~]$ sudo docker start test1
test1
[tom@archlinux ~]$ pid=$(sudo docker inspect -f '{{.State.Pid}}' test1)
[tom@archlinux ~]$ sudo ip netns attach test1 "$pid"
[tom@archlinux ~]$ sudo ip l add mvl1 link enp3s0 type macvlan
[tom@archlinux ~]$ sudo ip l set mvl1 netns test1
[tom@archlinux ~]$ sudo ip netns exec test1 ip l set mvl1 up
[tom@archlinux ~]$ sudo ip netns exec test1 ip a add 192.168.1.2/32 peer 192.168.1.1 dev mvl1
[tom@archlinux ~]$ sudo ip netns exec test1 ip r add default via 192.168.1.1
[tom@archlinux ~]$ sudo docker attach test1
[root@ec6541f4fe79 /]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
10: mvl1@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 12:3a:1a:a6:e6:7f brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.168.1.2 peer 192.168.1.1/32 scope global mvl1
       valid_lft forever preferred_lft forever
[root@ec6541f4fe79 /]# ip r
default via 192.168.1.1 dev mvl1 
192.168.1.1 dev mvl1 proto kernel scope link src 192.168.1.2 
[root@ec6541f4fe79 /]# ping -c 3 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.533 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.282 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.249 ms

--- 192.168.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2024ms
rtt min/avg/max/mdev = 0.249/0.354/0.533/0.126 ms
[root@ec6541f4fe79 /]# ping -c 3 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=55 time=1.12 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=55 time=1.08 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=55 time=1.09 ms

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 1.075/1.096/1.122/0.019 ms
[root@ec6541f4fe79 /]# exit
[tom@archlinux ~]$ sudo ip netns del test1
[tom@archlinux ~]$ 
  • 0
Reply Report

Trending Tags