Menu

Finally .... Static IP

2016-03-17
2016-07-30
  • Pedropa Ramos

    Pedropa Ramos - 2016-03-17

    Finally, after much searching on the Internet and try to use so failed the tutorial that appears on the download page, I found a way to set a static IP to our raspbx.

    I use a raspberry Pi2 and .img 06/03/2016:

    Forget all the other tutorials that are old, because, the only file you have to modify is in the following directory:
    /etc/dhcpcd.conf

    For this we use the nano /etc/dhcpcd.conf command in the console.

    Within this directory appears much information, but we must go down down completely and add the following lines:

    interface eth0 (It can be eth1, eth2... use command ifconfig to see the name)
    static ip_address=XXX.XXX.XXX.XXX/XX Static IP for raspberry/ Netmask, value depends on our LAN.
    static routers=XXX.XXX.XXX.XXX Here we put our gateway router.
    domain_name_servers=XXX.XXX.XXX.XXX DNS, here we can also put our gateway or DNS ruter we want.

    In short, taking an example my local network and my raspberry, the lines should look like this:

    interface eth0
    static ip_address=192.168.1.10/24
    static routers=192.168.1.1
    static domain_name_servers=192.168.1.1

    After adding these lines, we proceed with Ctrl + O and Enter to save the changes and our raspberry and start with static IP selected (192.168.1.10).

    A greeting from Spain!!!


    Definitivamente, despues de mucho buscar por internet e intentar utilizar de forma fallida el tutorial que aparece en la pagina de descarga, encontré la manera de establecer una IP estática a nuestra raspbx.

    Yo utilizo una raspberry Pi2 y la .img 06/03/2016:

    Olvidemos todos lo demas tutoriales que están antiguos, ya que, el unico archivo que tenemos que modificar está en el siguiente directorio:
    /etc/dhcpcd.conf

    Para ello debemos utilizar el comando nano /etc/dhcpcd.conf en la consola de comandos.

    Dentro de este directorio, aparece mucha información, pero nosotros, debemos de bajar hacia abajo del todo y agregar las siguientes lineas:

    interface eth0 (Podría ser eth1, eth2... utilizar comando "ifconfig" para ver el nombre)
    static ip_address=XXX.XXX.XXX.XXX/XX IP la estatica para raspberry/Mascara, dependera de nuestra LAN.
    static routers=XXX.XXX.XXX.XXX Aqui ponemos la puerta de enlace de nuestro ruter.
    static domain_name_servers=XXX.XXX.XXX.XXX Las DNS, aqui podemos poner tambien la puerta de enlace de nuestro ruter o las DNS que querámos.

    En definitiva, y tomando de ejemplo mi red local y mi raspberry, las lineas deberían de quedar asi:

    interface eth0
    static ip_address=192.168.1.10/24
    static routers=192.168.1.1
    static domain_name_servers=192.168.1.1

    Despues de agregar estas lineas, procedemos con Ctrl+O + Enter para guardar los cambios y ya nuestra raspberry iniciará con la IP estática seleccionada (192.168.1.10).

    Un saludo desde España!!!

     

    Last edit: Pedropa Ramos 2016-03-17
  • AlexCal

    AlexCal - 2016-03-30

    Thanks for this info Pedropa Ramos,

    i have put reference to this information under general discusion as well...

     
  • Anxifer

    Anxifer - 2016-07-30

    For whatever reason this doesn't always work. Sometimes the machine (at least in my case) still get's a random IP from the DHCP server.
    So I went on to setting the static address.the "oldfashioned" way: /etc/network/interfaces
    (address taken from example above)

    auto eth0
    iface eth0 inet static
    address 192.168.1.10
    netmask 255.255.255.0

    However I do also use the previously mentioned dhcpcd.conf for manually setting the default gateway (static routers=) and my preferred dns servers (static domain_name_servers=).
    It's simply the easiest way to get this annoying "comfortably-automatic-network-setup--bullshit" (dhcpd, resolvconf etc) to do what YOU want.

     

    Last edit: Anxifer 2016-07-31

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.