On 06/04/18 03:33, Bhangui, Avadhut Upendra wrote:
> I have a requirement that the solution running inside the container 
> should be able to communicate to services in public cloud and also 
> with some services on the host machine.
> 
> 1. How do I setup the networking of this container? 2. When it will 
> try to communicate to the service on the host machine, will request 
> be routed to machine over the physical network?

IMHO the simplest solution is to provide a "bridge" connection to your
eth device (wifi won't work) on your host. This way your containers
will get an IP from your LAN router and be available from every other
device on your internal LAN. If you then port forward to one of the
container IPs from your router then it's live on the 'net.

If using *buntu then make sure the bridge-utils package is installed
and if using a normal host desktop with NetworkManager then try these
two config files (change enp4s0f1 to your eth device, and address1)...


~ cat /etc/NetworkManager/system-connections/lxdbr0
[connection]
id=lxdbr0
uuid=2140d6a8-fb95-4d93-9488-58b64e216b81
type=bridge
interface-name=lxdbr0
permissions=

[bridge]
stp=false

[ipv4]
address1=192.168.X.XX/24,192.168.X.1
dns=1.1.1.1;
dns-search=local.lan;
method=manual

[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=ignore


~ cat /etc/NetworkManager/system-connections/enp4s0f1
[connection]
id=bridge-slave-enp4s0f1
uuid=f9691217-52c2-499e-b310-d5ccd7e1373f
type=ethernet
interface-name=enp4s0f1
master=lxdbr0
permissions=
slave-type=bridge

[ethernet]
auto-negotiate=true
mac-address=80:FA:5B:00:2C:48
mac-address-blacklist=

[ipv4]
dns-search=
method=link-local

[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto


OR... if using systemd-networkd then try these...


~ cat /etc/systemd/network/MyBridge.netdev
[NetDev]
Name=lxdbr0
Kind=bridge


~ cat /etc/systemd/network/MyBridge.network
[Match]
Name=lxdbr0

[Network]

#DHCP=ipv4
Address=192.168.X.XX/24
Gateway=192.168.X.XX
DNS=1.1.1.1


~ cat /etc/systemd/network/MyEth.network
[Match]
Name=e*

[Network]
Bridge=lxdbr0

Attachment: pEpkey.asc
Description: application/pgp-keys

_______________________________________________
lxc-users mailing list
lxc-users@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-users

Reply via email to