Ir al contenido
  • +31 653-919-302
Cafayate.Net
  • 0
  • 0
  • Inicia sesión
  • Nederlands English (US) Español (AR)
  • Contáctanos
  • Inicio
  • Blog
  • Empleos
  • Contáctanos
Cafayate.Net
  • 0
  • 0
    • Inicio
    • Blog
    • Empleos
    • Contáctanos
  • +31 653-919-302
  • Nederlands English (US) Español (AR)
  • Inicia sesión
  • Contáctanos

DNS resolution for LXC in Ubuntu 14.04

  • Todos los blogs
  • Tech Blog
  • DNS resolution for LXC in Ubuntu 14.04
  • 5 de marzo de 2021 por
    Administrator

    Working with LXC (Linux containers) in Ubuntu is very easy but by default you need to know the IP address of new containers to connect to services (ssh, database, webserver, etc.) running on them.

    With some minor configuration you can connect to your containers using a domain name like that

    $ sudo lxc-create --name container1
    $ sudo lxc-start --name container1 --daemon
    $ ssh ubuntu@container1.lxc

    In Ubuntu 14.04 Trusty Tahr, lxc-create use by default the Ubuntu template and it will create a user called ubuntu, to change it take a look at the template options with lxc-create -t ubuntu -h.

    To set up the internal DNS resolution on your machine, you must edit /etc/default/lxc-net and uncomment the line

    LXC_DOMAIN="lxc"

    Also you need to create the file /etc/NetworkManager/dnsmasq.d/lxc.conf with the following content

    server=/lxc/10.0.3.1

    This will redirect DNS queries for *.lxc hosts to the dnsmasq instance running on 10.0.3.1 that manage DHCP and DNS for containers.

    After that restart networking related services

    $ sudo service lxc-net stop
    $ sudo service lxc-net start
    $ sudo service network-manager restart

    For the lxc-net service you can’t use the restart command, you must use the stop/startcommands to reload the configuration.

    If you had some containers running, do not forget to restart them

    $ sudo lxc-stop --name container1
    $ sudo lxc-start --name container1 --daemon

    Finally to check that everything works you can use, for example, the ping command and you must see something like this

    $ ping -c 3 container1.lxc
    PING container1.lxc (10.0.3.8) 56(84) bytes of data.
    64 bytes from 10.0.3.8: icmp_seq=1 ttl=64 time=0.072 ms
    64 bytes from 10.0.3.8: icmp_seq=2 ttl=64 time=0.125 ms
    64 bytes from 10.0.3.8: icmp_seq=3 ttl=64 time=0.113 ms
    
    --- psql.lxc ping statistics ---
    3 packets transmitted, 3 received, 0% packet loss, time 2000ms
    rtt min/avg/max/mdev = 0.072/0.103/0.125/0.024 ms
    
    en Tech Blog
    Linux: Turn On TCP SYN Cookie Protection

    Diseñado para empresas

    Somos un equipo de personas apasionadas cuyo objetivo es mejorar la vida de todos a través de productos revolucionarios. Creamos grandes productos para resolver sus problemas empresariales. Nuestros productos están diseñados para pequeñas y medianas empresas dispuestas a optimizar su rendimiento.

    Contáctenos

    Plantexel
    Pedernera
    Salta Capital 
    Argenina

    • +31 653-919-302
    • [email protected]
    Síganos
    Copyright © Plantexel
    Nederlands | English (US) | Español (AR)