Public IP in the CT

root@vorash:~# lxc launch ubuntu:16.04 c1
Creating c1
Starting c1
root@vorash:~# lxc list c1
+------+---------+----------------------+-----------------------------------------------+------------+-----------+
| NAME |  STATE  |         IPV4         |                     IPV6                      |    TYPE    | SNAPSHOTS |
+------+---------+----------------------+-----------------------------------------------+------------+-----------+
| c1   | RUNNING | 10.178.245.12 (eth0) | fd42:3f9b:e713:ce99:216:3eff:fe1f:f9e7 (eth0) | PERSISTENT | 0         |
+------+---------+----------------------+-----------------------------------------------+------------+-----------+
root@vorash:~# ping 149.56.148.6
PING 149.56.148.6 (149.56.148.6) 56(84) bytes of data.
^C
--- 149.56.148.6 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms

root@vorash:~# lxc network set lxdbr0 ipv4.routes 149.56.148.6/32
root@vorash:~# lxc exec c1 bash
root@c1:~# ip -4 addr add dev eth0 149.56.148.6/32 preferred_lft 0
root@c1:~# exit
root@vorash:~# lxc list c1
+------+---------+----------------------+-----------------------------------------------+------------+-----------+
| NAME |  STATE  |         IPV4         |                     IPV6                      |    TYPE    | SNAPSHOTS |
+------+---------+----------------------+-----------------------------------------------+------------+-----------+
| c1   | RUNNING | 149.56.148.6 (eth0)  | fd42:3f9b:e713:ce99:216:3eff:fe1f:f9e7 (eth0) | PERSISTENT | 0         |
|      |         | 10.178.245.12 (eth0) |                                               |            |           |
+------+---------+----------------------+-----------------------------------------------+------------+-----------+
root@vorash:~# ping 149.56.148.6
PING 149.56.148.6 (149.56.148.6) 56(84) bytes of data.
64 bytes from 149.56.148.6: icmp_seq=1 ttl=64 time=0.062 ms
^C
--- 149.56.148.6 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.062/0.062/0.062/0.000 ms
root@vorash:~# 

The above is on an OVH server with failover IPs.

2 Likes