From Containers can not ping host

I can’t ping container from host and revers.
I can ping containers from all other host.
What is wrong?

Please can you provide your network config and container config.

this is my simple profile:
config:
environment.http_proxy: “”
user.network_mode: “”
description: Default LXD profile
devices:
eth0:
name: eth0
nictype: macvlan
parent: eth0
type: nic
root:
path: /
pool: default
type: disk
name: lanprofile

and i create a container with this command

lxc launch -p lanprofile ubuntu:18.04 test

route in my host is:
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.74.0.1 0.0.0.0 UG 0 0 0 eth0
10.74.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.74.0.0 0.0.0.0 255.255.255.0 U 0 0 0 lxdbr0
and route from container is
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.74.0.1 0.0.0.0 UG 0 0 0 eth0
10.74.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

There is missing some virbr0 in my host i think.

Ah, so you’re using macvlan. I’m afraid that macvlan (and ipvlan) devices do not allow the containers to communicate with the host (and vice versa). This is an inherent characteristic in macvlan device type in the Linux kernel.

You could try using a bridge instead of macvlan.

ok how?
do you have any desc. how to do that? Thanks

Take a look at https://openschoolsolutions.org/set-up-network-bridge-lxd/

ok Thanks.
Can i install bridge and create new profile and add or change all my containers to that profile?

Yep that should be fine.

i did step by step from doc. you have sent .
at final command:
lxc config device add my_containers eth0 nictype=bridged parent=br0 name=eth0
Error: Invalid devices: Device validation failed “eth0”: Unsupported device type

You missed the device type, try

lxc config device add my_containers eth0 nic nictype=bridged parent=br0 name=eth0

it’s not working. i add container test. then test ifconfig show 3 entry lo for 127.0.0.1 and eth0 where show nothing for ipv4 and br0 show my correct ip. 10.74.0.13 but i can’t use it.
i can not ping it i can’t see any host from this conatiner

Please can you post all of your network config, profile config and container configs.

Thanks

my host , /etc/network/interfaces (its ubuntu upgraded from 16 to 18)

auto eth0
iface eth0 inet static
        address 10.74.0.8
        netmask 255.255.255.0
        network 10.74.0.0
        broadcast 10.74.0.255
        gateway 10.74.0.1

and ifconfig is

eth0 = 10.74.0.8
lxdbr0 = 10.110.1235.1 
route -n  in host 
0.0.0.0         10.74.0.1       0.0.0.0         UG    0      0        0 eth0
10.74.0.0       0.0.0.0         255.255.255.0   U     0      0        0 eth0
10.110.235.0    0.0.0.0         255.255.255.0   U     0      0        0 lxdbr0

create container wilth all default

lxc launch ubuntu:18.04 test

At this point container has ip in lxdbr0 10.110.235.xx and everything is working ping in and out ,…

route -n is
0.0.0.0         10.110.235.1    0.0.0.0         UG    100    0        0 eth0
10.110.235.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
10.110.235.1    0.0.0.0         255.255.255.255 UH    100    0        0 eth0

i want to gave container my ip rang
then go to /etc/netplan/50… .yaml
and set the dhcp to no and gave ip addresses
this ip is working to see all other host but not master of container (ip is the same rang 10.74.0.x/24)
and gateway is 10.74.0.1.
and host can’t see containers.
i used doc you send it to me and reconfigure 50xxx.yaml to

network:
    ethernets:
        eth0:
            dhcp4: no
    version: 2
    bridges:
        lxdbr0:
            dhcp4: no
            addresses:
            - 10.74.0.13/24
            gateway4: 10.74.0.1
            nameservers:
                addresses:
                - 10.74.0.1
            interfaces:
            - eth0

and gave container

lxc config device add test eth0 nic nictype=bridged parent=lxdbr0 name=eth0

result is the same but container not suppose to se other host.

I’ve modified your post to use code formatting to make it easier to read.

There are several issues here:

  1. You need to create a new bridge, i.e one not called lxdbr0 as that is the internal LXD bridge. So change your netplan bridges section to create a new bridge, suggest br0.
  2. Your container needs to be parented to the new bridge, not the lxdbr0 bridge, so the parent= part should be parent=br0.
  3. You should also ensure that your eth0 on the host doesn’t have any IP addresses, and instead your new bridge has the IP that your eth0 had.

Alternatively if you do not need the container to talk to the host you could abandon using bridges and just use macvlan:

lxc config device add test eth0 nic nictype=macvlan parent=eth0 name=eth0

i create a new bridge br0 and and add the device to container
---------------------------±--------±------------------±-----±----------±----------+
| test | RUNNING | 10.74.0.7 (br0) | | CONTAINER | 0 |
±--------------------------±--------±------------------±-----±----------±----------+

and from container i have ifconfig bro=10.74.0.7 and etho har no address.
it’s not working

Thank you it’s working now.