Thursday, May 24, 2007

Linux (Ubuntu) Network Install

Introduction

Some days ago I had to install Ubuntu Breezy – a GNU/Linux flavour based on Debian and powered by apt-get – on four machines and I had only one CD-Rom available. And doing some fast calculations you can find out that it’s faster to install through a 100Mbps LAN (~12.5 Mb/s highest peek) than using a normal 52x CD-Rom.

Initially, the idea was to load the boot sector directly from the onboard network card. Unfortunately, I wasn’t able to do so (it skipped network boot as if it didn’t detect anything) and I decided to stick with that sometimes useful floppy disk and include a small boot sector that had the drivers included.

Ready to start?

Setting up the server

First off, you'll need a server where your clients will be connecting. That server must have a small FTP, HTTP and DHCP server and, obviously, an Ubuntu installation CD available. The DHCP allows your clients to connect to your network and the HTTP/FTP server will deliver installation files and package repositories.

Our FTP server will be tftpd-hpa. On Ubuntu/Debian this is a matter of

CODE:
  1. root@server$ apt-get install package-name

and that’s it, everything gets installed and set up. Let’s install everything at once:

CODE:
  1. root@server$ apt-get install tftpd-hpa apache2 dhcp3-server

Now it’s time to copy the content of the Ubuntu cd. Just do

CODE:
  1. root@server:/var/lib/tftpboot$ mkdir ubuntu
  2. root@server:/var/lib/tftpboot$ mount -o loop /var/lib/tftpboot/ubuntu-5.10-install-i386.iso /var/lib/tftpboot/ubuntu

In order to get an ISO of your installation CD, you can do (astonish yourself)

CODE:
  1. root@server$ cat /dev/hdb > ubuntu-5.10-install-i386.iso

where hdb is your CD-Rom device. It can be anything else other than hdb so you’d better figure out with dmesg (root@server # dmesg) or doing whatever suits you.

Make a symlink from apache's root to the mounted ISO

CODE:
  1. root@server:/var/www # ln -s /var/lib/tftpboot/ubuntu/

configure the DHCP server according to your network:

CODE:
  1. root@server:~ # cat /etc/dhcp3/dhcpd.conf
  2. ping-check = 1;
  3. filename = "ubuntu/install/netboot/pxelinux.0";
  4. subnet 192.168.1.0
  5. netmask 255.255.255.0 {
  6. range 192.168.1.10 192.168.1.254;
  7. }
CODE:
  1. root@server:~ # /etc/init.d/dhcp3-server restart
  2. Stopping DHCP server: dhcpd3.
  3. Starting DHCP server: dhcpd3.

And now run the clients. If you were able to see the Ubuntu boot prompt, that’s it. Now you just have to carry on with the installation. Otherwise, if you didn’t see anything and the boot continued as usual – just like happened to me – then keep reading this tutorial.The alternative is, like I said before, using a boot disk with the drivers. Etherboot has what we’re looking for. Download the latest version and read the README file. Then you just have to find out which network card you have and follow the very quick instructions.


taken from: http://mywheel.net/blog/index.php/ubuntu-network-install/

For other distros it's probably the same except for the packages download, here we used apt-get for downloading the needed packages, in other distros you may have some other way of downloading the packages like yum or you can always can go the internet and search for it.

Friday, May 18, 2007

Save a partition directly to a compressed file

To save a partion directly to a compressed file in linux is very easy regardless of the filesytem, you can save for example a NTFS (Windows NT File System) whith this.

To save the partition and later restore it, we are going to use three programs the first is 'dd' the which is used to make exact copies of partitions and restore them and the others are 'bzip2' which is used to compress and 'bunzip' to uncompress.

In order to save a partition to a compress a partition to a compress file, just do:


# dd if=/dev/hda2 bs=10M | bzip2 > /.../hda2_save.bz2


Where '/.../' must be replaced with the path to the dir where you want your partition compress save to be.

Has you can see above 'dd' has no 'of' (output file) so it's output will be the standart output (the shell), wich we redirect with '|' (pipe) to 'bzip2' standart input (which if not redirected is the keyboard), buzip2 will continuously compress the stream of data coming from 'dd', and that's it.




In order to save a partition to a compress a partition to a compress file, just do


# bunzip2 /.../hda2_save.bz2 --stdout | dd of=/dev/hda2


Where '/.../' must be replaced with the path to the dir where you want your partition compress save is.

Has you can see above 'bunzip2' has the option '--stdout' wich means that it will uncompress the file to the standart output (the shell) wich we redirect with '|' (pipe) to 'dd' standart input (which if not redirected is the keyboard).

Thursday, May 10, 2007

Instalar drivers da Nvidia em Ubuntu Feisty

A instalação foi realizada no meu notebook. A placa de vídeo aqui é uma NVIDIA GeForce 6150 256MB

Faça uma cópia de segurança do aquivo xorg.conf antes de iniciar a instalação.

$ sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf_bkp

1- Removendo pacotes antigos

$ sudo apt-get --purge remove nvidia-glx nvidia-settings nvidia-kernel-common

2- Instalando pacotes necessários

Certifique-se de ter habilitado os repositórios universe e multiverse

$ sudo apt-get install linux-restricted-modules-$(uname -r) build-essential xserver-xorg-dev

3- Baixe o driver aqui!

Esse é o ultimo release do driver

Mais informações sobre o driver aqui!

www.nvidia.com

4- Edite o arquivo linux-restricted-modules-common

$ sudo gedit /etc/default/linux-restricted-modules-common

Altere a linha DISABLED_MODULES=”"

Para DISABLED_MODULES=”nv”

5- Entrando em modo texto

Precione as teclas Ctrl + Alt + F1 e efetue o login. Não se assuste esse é o lado negro da força.

Após logado no modo texto vamos parar o gdm.

6 - Parando o gdm

$ sudo /etc/init.d/gdm stop

7- Executando o driver

Entre no diretório em que o foi salvo o aquivo .run

Transforme o aquivo em executável e em seguida execute o aquivo .run

$ sudo chmod +x NVIDIA-Linux-x86-1.0-9755-pkg1.run

A instalação e bem tranquila e só responder Ok em quase todas as perguntas. Só responda não na pergunta em que ele diz não ter um kernel compilado no sistema, se você aceitaria fazer o download desse kernel no site da nvidia.

$ sudo sh ./NVIDIA-Linux-x86-1.0-9755-pkg1.run

8 - Reinicie o sitema

$ sudo shutdown -r now

Pronto driver instalado!

9- Verificando a instalação

O primeiro sintoma que ocorreu no pc após a instalação do driver foi uma tela preta com o logo da nvidia antes de iniciar o gdm.

No menu Aplicações->Ferramentas do Sistema aparecerá a opção NVIDIA X Server Settings.

No terminal digite:

$ glxinfo | grep direct

Deve retornar

$ direct rendering: yes


retirado de: http://dfthiagodf.wordpress.com/2007/03/27/instalando-driver-nvidia-no-ubuntu-feisty/

Monday, May 7, 2007

Seeing and changing your DNS servers

To see which dns server that as been assingned to your by dhcp or inputed manualy, just do:

cat /etc/resolv.conf

To alter (and also see) your dns servers you can always edit /etc/resolv.conf using a text editor like vi or gedit or any other for vi do the following:

# vi /etc/resolv.conf

for gedit the following:

# gedit /etc/resolv.conf

Starting, Stoping and Restarting Services in Linux

To start, stop and restart a service in ubuntu (probaly in all other distros), you go to /etc/init.d, there you have the scripts to all the services (ex: dhcp, newtworking, ...).

For example if you want to stop the dhcp service you just need to do :

# sudo /etc/init.d/dhcp stop

to start it again do:

# sudo /etc/init.d/dhcp start

to restart it do:

# sudo /etc/init.d/dhcp restart

For the other services you just change "dhcp" to the name service script in /etc/init.d.
As you migth already noticed, you can see which services you have by seeing which scripts exist in /etc/init.d.

Friday, May 4, 2007

Basic Use of NetCat (Windows e Linux)

Netcat is already avaible in linux for windows you can download it, it's free.


TCP
---------------------------------------
With the comand below you can start a netcat server in any TCP port (here we use 53), in you local machine, and lets assume your local machine has the following IP 192.136.49.47.

# sudo nc -l -p 53

Now in another machine you can connect to the server at 192.136.49.47:53, with netcat as a client.

# sudo nc 192.136.49.47 53

To see if it's working you can type text in the bash (comand line) of the server or client and press enter and see if the text you inputed reaches the other machine, this is a simple and very reliable way to test connections between machines, and also firewalls

Bellow we have the same but for the UDP protocol.

UDP
------------------------------------
# sudo nc -l -p 53 -u

# sudo nc -u 192.136.49.47 53

Thursday, May 3, 2007

How to wire Ethernet and Console Cable (Cisco - Roll Over)

Cables form layer 1 of the network — the physical layer. Properly connecting cables is fundamental to healthy network communication. Faulty connections could interrupt service or cause packets to be dropped. Without a clear understanding of cabling, you won’t be able to troubleshoot or design your LAN or WAN. Additionally, knowledge of cable types is important for certification tests like the Cisco CCNA/CCENT.


Cabling basics for network admins

  • Your cable works at layer 1 — Physical of the OSI Model. Also at that layer are the 1’s and 0’s that traverse the cable as an electrical or light signal (depending on what type of cabling you are using).
  • Unshielded twisted pair (UTP) copper cable is used for many functions in network cabling: Ethernet, Serial, ISDN, Console, and more.
  • While you could put different ends on a UTP cable, typically it will have a RJ45 end with 8 pins.
  • With a normal Ethernet cable, the wires run straight through, from one end to the other. Straight-through cables are used to connect a PC to a switch, as in Figure A-1 and Figure A-2. Where each one uses one off the cabling standards, the T568B and T568B
 Figure A-1 - Straight-Through Cable 


Figure A-2 - Straight-Through Cable 

Graphic Courtesy of Cisco Systems
  • With a crossover cable (Figure B), the source and destination of the UTP wires are crossed. This allows you to use it to connect a PC to PC, switch to switch, or router to router.
  • In a crossover cable we use both off the cabling standads, T568A and T568B, one in each end, if one end uses T568B the other uses T568A, and vice-versa.



Figure B - Cross Over Cable 


Graphic Courtesy of Cisco Systems
Now, how is cabling for Cisco routers and switches different?


Cisco console and AUX port cabling
There are a few differences between Cisco cabling and other network device cabling. Two things immediately come to mind:
  • Cisco routers, switches, and firewalls use a special “rolled” cable for console and auxiliary port access.
  • Cisco offers intelligent serial cabling.
One of the most confusing things to Cisco newcomers is the concept of the console cable. Other SMB and home-networking devices don’t usually have a console port. With those devices, they receive a DHCP IP address and then you can configure them over the network from there. With Cisco devices, there is no IP address on the device, and you must first use the console port and console cable to configure the router, switch, or firewall OOB (out of band).
The Cisco console cable is a special cable. It isn’t wired like an Ethernet cable. However, if you didn’t have a console cable, you could cut off the end of a straight-through Ethernet cable, change the pin out, and recrimp it to make it a console cable.
Below, you can see the pin out of a console cable. The console cable is a “rolled” cable, because if you look at the pins from one end to the other, it is as if the end was rolled over (the order is flipped), as in Figure C.

Figure C - Console Cable (Rolled Cable)

Graphic Courtesy of Cisco Systems
Traditionally Cisco console cables were RJ45-RJ45 and then you would use a RJ45-DB9 adaptor to connect it to your PC’s serial port (COM port). Today, new Cisco devices come with console cables that have a DB9 adaptor integrated/molded to the cable on one end (Figure D). Keep in mind that the data moving across the console cable is serial data (not Ethernet).

Figure D - RJ45-DB9 adaptor


Graphic Courtesy of Cisco Systems
For those equipements tha don't have an integrated DB9 ports, here how you can make your own DB9 adapter:


Click on the images to enlarge
While what I said above concerning console cables is true for most Cisco devices, there are variations on the console cable. For more detailed information about Cisco console and AUX port cabling (including the pin-out for a console cable so that you can make your own), see this Cisco document Cisco Cabling Guide for Console and AUX Ports.

David Davis has worked in the IT industry for 15+ years and holds several certifications, including CCIE, CCNA, CCNP, MCSE, CISSP, VCP. He has authored hundreds of articles and numerous IT training videos. Today, David is the Director of Infrastructure at Train Signal.com. Train Signal, Inc. is the global leader in video training for IT Professionals and end users.

Taken From: http://blogs.techrepublic.com.com/networking/?p=649
and added some stuff about the cabling standards (like here)


Another good reference for building ethernet cables is:
http://www.ertyu.org/steven_nikkel/ethernetcables.html