Instalando servidor de e-mail postfix, imap, dovecot

Tutorial básico para criar um servidor de e-mails com postfix, imap, pop, mysql, devecot e cliente de e-mails web roundcube.

opção rápida: http://www.iredmail.org

Estou utilizando o GNU/Linux Debian amd64

instalar o postfix:

# apt-get install postfix

Continuar lendo Instalando servidor de e-mail postfix, imap, dovecot

iptables

Uma configuração de iptables

Você pode aprender tudo sobre Iptables aqui: http://www.guiafoca.org/cgs/guia/avancado/ch-fw-iptables.html

Compartilha a rede externa com a interna e liberar as principais portas do servidor:

#!/bin/bash
#################### Inicio Firewall #################################

modprobe ip_nat
modprobe ip_nat_ftp
modprobe ip_queue
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_tables
modprobe iptable_filter
modprobe iptable_nat
modprobe iptable_mangle
modprobe ipt_state
modprobe ipt_limit
modprobe ipt_multiport
modprobe ipt_mac
modprobe ipt_string
## Limpando as Regras existentes #######
iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -t filter -F
iptables -X
iptables -Z

## Definindo politica padrão (Nega entrada e permite saida)
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT

## Estabelece relação de confiança entre maquinas da rede local eth0(rede local)
iptables -A INPUT -i eth1 -s 10.1.0.0/255.255.255.0 -j ACCEPT
iptables -A INPUT -i eth1 -m state –state NEW -j ACCEPT
iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT

############################ Compartilhamento Internet #########################
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward

### SSH
iptables -A INPUT -p tcp –dport 22 -j ACCEPT
### HTTP
iptables -A INPUT -p tcp –dport 80 -j ACCEPT
### HTTPS
iptables -A INPUT -p tcp –dport 443 -j ACCEPT
### SMPT
iptables -A INPUT -p tcp –dport 25 -j ACCEPT
### IMAP
iptables -A INPUT -p tcp –dport 143 -j ACCEPT
### IMAPS
iptables -A INPUT -p tcp –dport 993 -j ACCEPT
### POP
iptables -A INPUT -p tcp –dport 110 -j ACCEPT
### POPS
iptables -A INPUT -p tcp –dport 465 -j ACCEPT
### ???
iptables -A INPUT -p tcp –dport 587 -j ACCEPT
### POPS
iptables -A INPUT -p tcp –dport 995 -j ACCEPT
### ICMP e ping
iptables -A INPUT -p icmp  -j ACCEPT

######################################## Fim ###################################

 

Para salvar no Debian:

# iptables-save > /etc/default/iptables

# iptables-restore < /etc/default/iptables

 

Fontes:

http://www.guiafoca.org/cgs/guia/avancado/ch-fw-iptables.html

http://deangerber.com/blog/2011/09/10/basic-iptables-firewall-configuration/

http://www.rackspace.com/knowledge_center/article/mail-server-opening-ports-in-the-linux-firewall

Instalando grub no Debian GNU/Linux com raid 1

Precisei instalar o Debian em um sistema com raid 1 e descobri que simplesmente o grub dava falha.

Depois de muito googlear, descobri que é necessário instalar o Debian, optar por não instalar o iniciador de boot. Reiniciar o instalador e entrar no modo rescuse, depois escolher o mapeamento correto para instalar o grub no /

procedimentos podem ser encontrados aqui:

https://wiki.debian.org/DebianInstaller/SataRaid

Use the following method only if you want to have a dual-boot system with Debian and the other operating system on the same Serial ATA RAID:

  1. Set up your fake RAID in the BIOS (see owners manual).
  2. Boot from a Debian installation media.
  3. Move the cursor to the Install boot menu entry (do not hit Enter yet):
    1. Press Tab to edit the kernel boot line.
    2. Add dmraid=true to the end of the line.
    3. Press Enter.
  4. Install Debian as usual, until you get to the disk partitioner. You will see your fake RAID as one disk with a confusing long name. Use it as if it were a single disk and configure your partitions any way you want, including LVM and friends.
  5. Complete the installation. The installation of GRUB may fail, but that is OK; GRUB needs to be reinstalled either way. If GRUB installation fails, select “continue without bootloader” to complete the Debian installation.
  6. Reboot as instructed by Debian Installer.
  7. Boot using the Debian installation media again.
  8. In the boot menu, go to Advanced Options, and move the cursor to “Rescue system” (do not hit Enter yet):
    1. Press Tab to edit the kernel boot line.
    2. Add “dmraid=true” without quotes to the end of the line.
    3. Press Enter.
  9. You will be presented with screens similar to the installation screens. Go through with them until you are asked to choose a root filesystem to mount and use.
  10. Choose the first /dev/dm-? (? is a number). You will get a command prompt.
  11. (Optional) Type bash into the prompt, for easier command line editing and command history.
  12. Modify /etc/default/grub (e.g. nano /etc/default/grub) and uncomment GRUB_DISABLE_LINUX_UUID=true (699437). Save the file and exit the editor.
  13. Type update-grub and press enter. This is very important, because otherwise the GRUB boot menu later wont be able to display your freshly installed kernel!
  14. Type grub-install /dev/mapper/ and press tab and tab again, you will get the names of the fake raid partitions.
    1. Complete grub-install /dev/mapper/ with the name of your whole fake disk.

      For example grub-install /dev/mapper/isw-jggdha7s-SYS (Note that there is no number at the end of the name). You may have something like /dev/mapper/isw-jggdha7s-SYS and /dev/mapper/isw-jggdha7s-SYS1, or /dev/mapper/isw-jggdha7s-Volume and /dev/mapper/isw-jggdha7s-Volume1. Choose the one without the partition number and press enter.

    2. Everything should install now without an error.
  15. Type exit (twice if you did step 11). Now you should be back in the rescue system menu. Choose the Reboot system option. Now boot off your fake RAID and see GRUB starting your new Debian installation.

 

Por fim precisei editar na hora do boot o local correto de boot, vc consegue isso com digitando “e” no menu de boot.

Depois de bootar entrei em /boot/grub/grub.cfg, e alterei ali o local de boot tbm para o mapeamento do Raid correto.

Ainda é necessário fazer o sistema sempre apontar para o mapeamento certo do raid, mas isso eu não fiz ainda 😀

Ubuntu e VirtualBox erro Kernel driver not installed (rc=-1908)

Se vc está instalando o virtualbox para sua irma em um Ubunto com kernel atualizado e já procurou varias coisas na internet e não resolveu…

Quem sabe isso ajude:
[code language=”bash”]

$ sudo apt-get install linux-headers-`uname -r`

#Reconfigure dkms and load module:
$ sudo dpkg-reconfigure virtualbox-dkms
$ sudo modprobe vboxdrv

[/code]

não é necessario reboot.

Fontes:
http://blog.inurl.com.br/2013/01/solucionando-erro-kernel-driver-not.html
http://askubuntu.com/questions/205154/virtualbox-etc-init-d-vboxdrv-setup-issue

Configurar IP fixo e IP via DHCP no Debian via terminal

# nano /etc/network/interfaces
ou
# vim /etc/network/interfaces

Agora vamos configurar. Lembrando que eth0 é o dispositivo correspondente à minha placa:

auto eth0
iface eth0 inet static
address 192.168.1.20
netmask 255.255.255.0
gateway 192.168.1.1

Broadcast não é necessário, pois ele é configurado automaticamente.

Obs.: Está é a minha configuração, provavelmente você terá que adaptar para a sua rede.

Se você utiliza uma placa de rede para acesso externo, como eth0, basta modificar “eth0” para “eth1”.

Agora vamos reiniciar a conexão de rede:

# /etc/init.d/networking restart

Pronto, configuração feita e é só aproveitar.

 

Fontes:

http://www.vivaolinux.com.br/topico/Iniciantes-no-Linux/Debian.Colocar-Ip-automatico

http://www.vivaolinux.com.br/dica/Configurando-placa-de-rede-para-IP-fixo-no-Debian

http://www.vivaolinux.com.br/topico/Debian/IP-FIXO

Clonezilla clonar HD ou partições

Clonezilla é um live cd/usb que possibilita a clonagem e recuperação de HDs inteiros e partições.

O interessante é que possibilita a restauração via HD externo ou rede via SSH, o que torna o serviço muito mais rápido quando temos varias máquinas para clonar.

Site oficial: http://clonezilla.org/

Instruções para bootar via USB: http://clonezilla.org/liveusb.php#linux-method-b

Mais:

http://www.hardware.com.br/artigos/clonezilla/

Chrome no Ubuntu

Instalar o Chrome no ubuntu 12.10:

$ wget -q -O – https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add –

$ sudo sh -c ‘echo “deb http://dl.google.com/linux/chrome/deb/ stable main” >> /etc/apt/sources.list.d/google.list’

$ sudo apt-get update

$ sudo apt-get install google-chrome-stable

Fontes:

http://www.itworld.com/software/304992/install-googles-chrome-browser-ubuntu-1210

Here’s How to Install Google Chrome in Ubuntu 12.10 (Quantal Quetzal)

http://www.diolinux.com.br/2012/10/como-instalar-google-chrome-no-ubuntu.html

http://ubuntued.info/como-instalar-o-ubuntu-12-10-quantal-quetzal-e-algumas-recomendacoes

BCM4322 Ubuntu 12.10

Placa wireless da broadcom não funciona com o Ubuntu 12.10

a solução pra mim foi fazer o seguinte:

# apt-get install bcmwl-kernel-source

# modprobe -r b43 ssb wl

# modprobe wl

fontes:

http://www.howopensource.com/2012/10/install-broadcom-sta-wireless-driver-in-ubuntu-12-10-12-04/

http://pkgs.org/ubuntu-12.10/ubuntu-multiverse-i386/firmware-b43-installer_015-14_all.deb.html

https://bugs.launchpad.net/ubuntu/+source/bcmwl/+bug/1075407

http://ubuntuforums.org/showthread.php?t=1979460

Recuperação de dados

Vou apresentar algumas ferramentas do mundo GNU que permitem recuperar dados, partições e arquivos de extensão especifica. Eles podem ser decisivos na hora que tudo deu errado.

Primeiro o magnifico TestDisk, com ele você pode recuperar partições inteiras!

Uso: http://www.hardware.com.br/livros/ferramentas-linux/usando-testdisk.html

Agora se você precisa recuperar aquivos deletados você pode usar o PhotoRec que foi criado inicialmente para recuperar fotos de cartões digitais, mas pode ser usado para recuperar em mídia agora. Ele recuperar até o que você não quer… tome cuidado.

Uso: http://www.hardware.com.br/livros/hardware/usando-photorec.html

e : http://www.vivaolinux.com.br/artigo/Recuperacao-de-Dados-com-o-PhotoRec

Temos também o dd_rescue que recupera os arquivos mesmo que eles estejam em setores defeituosos, em casos de arquivos ou imagens pode ser muito útil, pois mesmo copiando com dados imprecisos você consegue recuperar a parte boa do arquivo.

Uso: http://www.hardware.com.br/livros/ferramentas-linux/copiando-dados-hds-cds-defeituosos.html

Recomendo a leitura de :

http://www.hardware.com.br/livros/hardware/capitulo-sistemas-arquivos-recuperacao-dados.html

http://www.vivaolinux.com.br/artigo/Recuperando-discos-danificados-com-o-myrescue/?pagina=1

Criando partição maior que 2 TB no Linux

Descobri somente na pratica que o MBR está limitado para partições de até 2 TB, mas para maiores temos uma solução o GPT!

Para mais informações olhe as fontes!

Aqui vai como fazer:

Vendo dados do Disco

# fdisk -l /dev/sdb

Saida:

Disk /dev/sdb: 3000.6 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 364801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table

Criar um partição de 3 TB

# parted /dev/sdb

Saída:

GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)

Criando um novo rotulo do tipo GPT:

(parted) mklabel gpt

saída:

Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes
(parted)

Setar para TB a unidade de medida:

(parted) unit TB

Criando a partição com 3TB:

(parted) mkpart primary 0.00TB 3.00TB

Imprimindo o resultado:

(parted) print

Sample outputs:

Model: ATA ST33000651AS (scsi)
Disk /dev/sdb: 3.00TB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number  Start   End     Size    File system  Name     Flags
 1      0.00TB  3.00TB  3.00TB  ext4         primary

Saindo e salvando as mudanças:

(parted) quit

Agora utilize o mkfs.ext4 para formatar a partição criada!

# mkfs.ext4 /dev/sdb1

 

Pronto! Linux é foda né?

Fontes:

http://www.ibm.com/developerworks/br/linux/library/l-gpt/

http://www.cyberciti.biz/tips/fdisk-unable-to-create-partition-greater-2tb.html

http://www.vivaolinux.com.br/artigo/Exemplos-praticos-de-comandos-com-Parted?pagina=1