First of all, I am not that experienced in networking. I have three NIC in my system.
My netplan settings:
network:
ethernets:
enp5s0:
dhcp4: true
enp3s0:
dhcp4: false
addresses: [X.X.X.251/32]
nameservers:
addresses: [8.8.8.8, 1.1.1.1]
routes:
- to: 0.0.0.0/0
via: X.X.X.249
on-link: true
enp2s0:
dhcp4: false
addresses: [X.X.X.252/32]
nameservers:
addresses: [8.8.8.8, 1.1.1.1]
routes:
- to: 0.0.0.0/0
via: X.X.X.249
version: 2
Route Table
default via X.X.X.249 dev enp3s0 proto static onlink
default via 192.168.10.1 dev enp5s0 proto dhcp src 192.168.10.99 metric 100
10.0.0.0/16 dev lxdbr0 proto kernel scope link src 10.0.0.1 linkdown
192.168.10.0/23 dev enp5s0 proto kernel scope link src 192.168.10.99
192.168.10.1 dev enp5s0 proto dhcp scope link src 192.168.10.99 metric 100
enp5s0 is connected to local router. enp3s0 is public IP that I by default wanted to route through.
enp2s0 is the one by which I want to set the IP X.X.X.252 and want to attach it with a specific lxc container.
I want to get into lxc container If I want to ssh into X.X.X.252 or other traffic.
How Can I do that here?
$ lxc network list
+--------+----------+---------+-------------+---------+
| NAME | TYPE | MANAGED | DESCRIPTION | USED BY |
+--------+----------+---------+-------------+---------+
| enp2s0 | physical | NO | | 0 |
+--------+----------+---------+-------------+---------+
| enp3s0 | physical | NO | | 0 |
+--------+----------+---------+-------------+---------+
| enp5s0 | physical | NO | | 0 |
+--------+----------+---------+-------------+---------+
| lxdbr0 | bridge | YES | | 1 |
+--------+----------+---------+-------------+---------+
If I attach that to the container,
$ lxc network attach enp2s0 container eth0
$ lxc list
+--------+---------+-----------------------+------+------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+--------+---------+-----------------------+------+------------+-----------+
| container | RUNNING | 192.168.11.241 (eth0) | | PERSISTENT | 0 |
+--------+---------+-----------------------+------+------------+-----------+
It doesn't work and instead it routes through local network.
Please guide me where and what should I change for that?
Example of assigning a static address to a container once you have disabled the static address and DHCP on the device.
Then once its started..
You'll then need to setup the default correct default route..