CentOS 8 routed nic interface has no access to outside network

I have CentOS 8 LXD container configured with routed interface. LXD is installed via snap on Debian 10 host machine.

lxc init images:centos/8 c1
lxc config device add c1 eth0 nic nictype=routed parent=eth0 ipv4.address=138.*.16.151

/snap/bin/lxc list
+----------+---------+-----------------------+------+-----------+-----------+
|   NAME   |  STATE  |         IPV4          | IPV6 |   TYPE    | SNAPSHOTS |
+----------+---------+-----------------------+------+-----------+-----------+
| c1 | RUNNING | 138.201.16.151 (eth0) |      | CONTAINER | 0         |
+----------+---------+-----------------------+------+-----------+-----------+

According to this post
Routed notwork is not working with Centos 7 now [from the box] I have added the file route-eth0 inside /etc/sysconfig/network-scripts

So from container I can ping the LXD interface:

ping 169.254.0.1
PING 169.254.0.1 (169.254.0.1) 56(84) bytes of data.
64 bytes from 169.254.0.1: icmp_seq=1 ttl=64 time=0.026 ms

However pinging google is not possible:

ping google.com
ping: google.com: Name or service not known

Routes (cmd executed inside container):

ip r
default via 169.254.0.1 dev eth0 proto static metric 100
169.254.0.1 dev eth0 proto static scope link metric 100

ifcfg:

cat /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
DEVICE=eth0
NAME=eth0
BOOTPROTO=none <--- changed to "none" from "static" according to the post linked above
ONBOOT=yes
IPADDR=138.*.16.151
PREFIX=32
IPV6INIT=no
MTU=
cat /etc/sysconfig/network-scripts/route-eth0
169.254.0.1/128 dev eth0
default via 169.254.0.1 dev eth0

What have you set the container’s DNS resolution server to?

Can you ping an external IP (i.e is this a DNS issue or a network issue?)

Oh, I am sorry, its my bad. I switched to Google DNS servers and now everything works properly.

1 Like