Archive for the 'OpenBSD' Category

Com crear tunnels ssh inversos?

Un tunnel ssh invers significa crear un tunnel de destí a origen.

Imaginem que treballem en local fent una apliació web i tenim un apache corrent al nostre ordinador però volem ensenyar-ho a algú.

Doncs mitjançant un tunnel d’aquests podem obrir un flux de xarxa per tal de per exemple mostrar la pàgina sense necessitat d’obrir ports al nat de nostre router i senzillament donant una l’adreça i port d’algun servidor que tinguem.

Per fer això necessitem un servidor amb sistema tipu unix amb un servidor openssh i un ordinador amb client ssh(mac o linux per exemple, amb windows i putty segurament també es pot fer)

Exemple:

Tenim un apache corrent al port 8080 del nostre ordinador.

Tenim un servidor diguem-li servidor.com i volem obrir el flux al port 10000.

Doncs és tant simple com obrir un terminal en el nostre ordinador Mac o *nix:

mbp$ ssh servidor.com -R servidor.com:10000:localhost:8080 -N

Amb aquesta senzilla ordre crearem un tunnel de manera que quan algú posi al seu navegador, http://servidor.com:10000, podrà veure la web en aquest cas que estiguem preparant des del nostre portatil. Un cop executada la ordre no ha de passar res, el tunnel queda obert fins que el tanquem fent control+c.

El parametre -R significa exactament el que s’ha descrit enviar el flux de xarxa que entri pel servidor remot cap a la màquina origen del tunnel. El -N fa que no s’inicii una sessió de consola.

Nota: si volem obrir el tunnel  fent servir un usuari en concret(ex ricard) i especificar un port diferent(ex 4422) al per defecte:

mbp$ ssh -p4422 ricard@servidor.com -R servidor.com:10000:localhost:8080 -N

Installing OpenBSD from the network using PXE

In this post I will explain how to configure a OpenBSD server ready to install other servers entirely using the LAN. We use dhcp daemon and tftp daemon. DHCP will configure network and tftp will provide pxeboot and bsd.rd installation files.

We also prepare apache to provide installation packages. After this tutorial if you follow official openbsd manual, installation is very simple. Just chose http install, set your http server ip and set openbsd43 folder, select packages and that’s all. I wish you find it useful.

Preparing dhcpd


  # echo 'option domain-name "forniol.cat";
             option routers 192.168.1.1;
             option subnet-mask 255.255.255.0;
             option broadcast-address 192.168.1.255;
             option domain-name-servers 208.67.220.220;
             server-name "DHCPserver";
             server-identifier 192.168.1.1;

             default-lease-time 120;
             max-lease-time 120;

             subnet 192.168.1.0 netmask 255.255.255.0 {
                 filename "pxeboot";
                 range 192.168.1.36 192.168.1.250;
             }' > /etc/dhcpd.conf

  # /usr/sbin/dhcpd
  Executing dhcp server
  

Preparing tftpd


  # vi /etc/inetd.conf
    move down to line "#tftp dgram udp wait root ..."
    Push esc and type "d"
    Press space
    doing this, # shout disapear
    Push esc and type ":wq!"
    save and quit
  # ps aux | grep inetd | grep -v -e 'ps' -e 'grep inetd' | awk '{print $2}' > pid_inetd ;
  # kill -9 `cat pid_inetd` && rm pid_inetd
  Killing inetd server
  # /usr/sbin/inetd
  Start inetd again
  

Preparing files to load on boot

  # mkdir -p /tftpboot/etc
  # cp /bsd.rd /tftpboot
  # cp /usr/mdec/pxeboot /tftpboot
  # echo "set image /bsd.rd" > /tftpboot/etc/boot.conf
  

Preparing httpd


  # mkdir /var/www/htdocs/openbsd43
  

Copy all installation files inside this directory. The one’s marked are mandatory.
Look at this page (http://www.openbsd.org/ftp.html) and download the following files from a mirror.


    [x] base43.tgz
    [x] bsd
    [x] comp43.tgz
    [x] etc43.tgz
    [x] index.txt
    [x] man43.tgz
    [x] misc43.tgz
    [ ] game43.tgz
    [ ] bsd.mp
    [ ] bsd.rd
    [ ] xbase43.tgz
    [ ] xetc43.tgz
    [ ] xfont43.tgz
    [ ] xserv43.tgz
    [ ] xshare43.tgz

  # /usr/sbin/httpd
  It executes the http daemon
  

Make services to start on load


# echo "/usr/sbin/dhcpd" >> /etc/rc.local
# echo "/usr/sbin/httpd" >> /etc/rc.local

Having all that stuff configured and running just power on any computer where you want to install openbsd and select boot PXE. Ensure there’s no other dhcp server running on that network.

Últims Twitts

Posting tweet...