我拥有的:
LXC主机
# ifconfig
wg1: flags=209<UP,POINTOPOINT,RUNNING,NOARP> mtu 1420
inet 192.168.7.2 netmask 255.255.255.0 destination 192.168.7.2
...
enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.110 netmask 255.255.255.0 broadcast 192.168.1.255
...
lxdbr0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.7.56.1 netmask 255.255.255.0 broadcast 0.0.0.0
...
/etc/wireguard/wg1.conf
[Interface]
PrivateKey = my_private_key
Address = 192.168.7.2/24
[Peer]
PublicKey = my_public_key
AllowedIPs = 0.0.0.0/0
Endpoint = my_remote_server_ipv4:51194
PersistentKeepalive = 15
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 enp2s0
10.7.56.0 0.0.0.0 255.255.255.0 U 0 0 0 lxdbr0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp2s0
192.168.1.1 0.0.0.0 255.255.255.255 UH 100 0 0 enp2s0
192.168.7.0 0.0.0.0 255.255.255.0 U 0 0 0 wg1
LXC集装箱
# curl ifconfig.me
my_remote_server_ipv4
一切都很好,但是:
# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.7.56.100 netmask 255.255.255.0 broadcast 10.7.56.255
...
我想要的是:
# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet my_remote_server_ipv4 netmask 255.255.255.0 broadcast ...
...
我想在不更改容器中任何内容的情况下执行此操作。
更新。我想为我的家庭 lxc 容器分配一个公共 IP(由我的远程服务器拥有)。看来是不可能了...