MacVLAN & Proxy

Hi,

I Zabbix server in a container in LXD.
The host has Zabbix Agent.

Because I’m using MacVLAN the MAC Address is shared and there for the router can’t see the difference between the 2 machines as both have the same MAC. So my Idea was the add a Proxy device to 127.0.0.1 and connect to that but I still cannot get it to work.

Here is my Config:

devices:
eth0:
nictype: macvlan
parent: enp36s0f0
type: nic
root:
path: /
pool: default
type: disk
zab:
connect: tcp:127.0.0.1:10060
listen: tcp:0.0.0.0:10060
type: proxy

I then use NetCat like nc -v 127.0.0.1 10060 on both machine but
I get a failed: Connection refused.

What am I doing wrong? Is this type of thing possible on MacVLAN?

Um, no. Macvlan-devices have their own MAC-addresses.

Oh, How come I can not ping the Host from my container?

I checked the ARP table and it gets really odd results. Like,

xxx.xxx.xxx.xxx dev eth0 INCOMPLETE

What does ss -tlpn show inside the container?

Because that’s how macvlan works. You need a macvlan-interface on both the host and the container, or you need to use a bridge, like the documentation at Type: nic - LXD documentation explains.

I use macvlan with my containers and VMs myself and I just leave the parent-interface on the host unconfigured and instead make a macvlan-interface on the host as well. That way it all works like one would expect it to.

A bunch of stuff with the -l but with out it it shows:

ESTAB   0        0              127.0.0.1:49926          127.0.0.1:5432     users:(("zabbix_server",pid=510,fd=12))
ESTAB   0        0              127.0.0.1:5432           127.0.0.1:50066    users:(("postgres",pid=557,fd=9))
ESTAB   0        0              127.0.0.1:5432           127.0.0.1:50046    users:(("postgres",pid=555,fd=9)) 
ESTAB   0        0              127.0.0.1:5432           127.0.0.1:49780    users:(("postgres",pid=483,fd=9))
ESTAB   0        0              127.0.0.1:49846          127.0.0.1:5432     users:(("zabbix_server",pid=503,fd=12))
ESTAB   0        0              127.0.0.1:5432           127.0.0.1:49878    users:(("postgres",pid=527,fd=9)) 
ESTAB   0        0              127.0.0.1:49950          127.0.0.1:5432     users:(("zabbix_server",pid=528,fd=12))
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:49840    users:(("postgres",pid=515,fd=9))         
 ESTAB   0        0              127.0.0.1:49956          127.0.0.1:5432     users:(("zabbix_server",pid=536,fd=13))   
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:49956    users:(("postgres",pid=543,fd=9))         
 ESTAB   0        0              127.0.0.1:49780          127.0.0.1:5432     users:(("zabbix_server",pid=482,fd=16))   
 ESTAB   0        0              127.0.0.1:49878          127.0.0.1:5432     users:(("zabbix_server",pid=509,fd=12))   
 ESTAB   0        0              127.0.0.1:50046          127.0.0.1:5432     users:(("zabbix_server",pid=542,fd=12))   
 ESTAB   0        0              127.0.0.1:50024          127.0.0.1:5432     users:(("zabbix_server",pid=537,fd=12))   
 ESTAB   0        0              127.0.0.1:49982          127.0.0.1:5432     users:(("zabbix_server",pid=533,fd=12))   
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:49990    users:(("postgres",pid=549,fd=9))         
 ESTAB   0        0              127.0.0.1:50002          127.0.0.1:5432     users:(("zabbix_server",pid=531,fd=12))   
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:49796    users:(("postgres",pid=486,fd=9))         
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:49876    users:(("postgres",pid=525,fd=9))         
 ESTAB   0        0              127.0.0.1:50070          127.0.0.1:5432     users:(("zabbix_server",pid=499,fd=13))   
 ESTAB   0        0              127.0.0.1:50010          127.0.0.1:5432     users:(("zabbix_server",pid=547,fd=12))   
 ESTAB   0        0              127.0.0.1:50078          127.0.0.1:5432     users:(("zabbix_server",pid=500,fd=13))   
 ESTAB   0        0          192.168.2.213:8080        192.168.2.32:1757     users:(("nginx",pid=199,fd=138))          
 ESTAB   0        0              127.0.0.1:49836          127.0.0.1:5432     users:(("zabbix_server",pid=502,fd=12))   
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:50032    users:(("postgres",pid=554,fd=9))         
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:49804    users:(("postgres",pid=487,fd=9))         
 ESTAB   0        0              127.0.0.1:49804          127.0.0.1:5432     users:(("zabbix_server",pid=484,fd=11))   
 ESTAB   0        0              127.0.0.1:49894          127.0.0.1:5432     users:(("zabbix_server",pid=514,fd=12))   
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:50078    users:(("postgres",pid=559,fd=9))         
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:50010    users:(("postgres",pid=552,fd=9))         
 ESTAB   0        0              127.0.0.1:50032          127.0.0.1:5432     users:(("zabbix_server",pid=548,fd=12))   
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:49864    users:(("postgres",pid=523,fd=9))         
 ESTAB   0        0              127.0.0.1:49970          127.0.0.1:5432     users:(("zabbix_server",pid=529,fd=12))   
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:49936    users:(("postgres",pid=539,fd=9))         
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:49982    users:(("postgres",pid=546,fd=9))         
 ESTAB   0        0              127.0.0.1:49840          127.0.0.1:5432     users:(("zabbix_server",pid=505,fd=12))   
 ESTAB   0        0              127.0.0.1:49910          127.0.0.1:5432     users:(("zabbix_server",pid=512,fd=12))   
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:49910    users:(("postgres",pid=532,fd=9))         
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:49894    users:(("postgres",pid=530,fd=9))         
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:50002    users:(("postgres",pid=551,fd=9))         
 ESTAB   0        0              127.0.0.1:49936          127.0.0.1:5432     users:(("zabbix_server",pid=526,fd=12))   
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:49926    users:(("postgres",pid=534,fd=9))         
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:49846    users:(("postgres",pid=518,fd=9))         
 ESTAB   0        0              127.0.0.1:49876          127.0.0.1:5432     users:(("zabbix_server",pid=504,fd=12))   
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:49858    users:(("postgres",pid=521,fd=9))         
 ESTAB   0        0              127.0.0.1:50054          127.0.0.1:5432     users:(("zabbix_server",pid=540,fd=12))   
 ESTAB   0        0              127.0.0.1:49990          127.0.0.1:5432     users:(("zabbix_server",pid=538,fd=12))   
 ESTAB   0        0              127.0.0.1:49864          127.0.0.1:5432     users:(("zabbix_server",pid=507,fd=12))   
 ESTAB   0        0              127.0.0.1:49796          127.0.0.1:5432     users:(("zabbix_server",pid=485,fd=15))   
 ESTAB   0        0              127.0.0.1:50066          127.0.0.1:5432     users:(("zabbix_server",pid=545,fd=12))   
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:49836    users:(("postgres",pid=511,fd=9))         
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:49950    users:(("postgres",pid=541,fd=9))         
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:49970    users:(("postgres",pid=544,fd=9))         
 ESTAB   0        0              127.0.0.1:49858          127.0.0.1:5432     users:(("zabbix_server",pid=506,fd=12))   
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:50024    users:(("postgres",pid=553,fd=9))         
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:50054    users:(("postgres",pid=556,fd=9))         
 ESTAB   0        0              127.0.0.1:5432           127.0.0.1:50070    users:(("postgres",pid=558,fd=9)) 

I also have other container using the Lxdbr0 interface as well as Docker using IPVlan. I’m not sure if using MacVLAN on the host would break things. I’m not too clued up with with SDN yet. But I know MacVLAN was what I needed for this as it has the fixed IP I need

Nothing is listening on 127.0.0.1:10060 which is where you’re forwarding the proxy device to.