quarta-feira, 9 de novembro de 2016

Como remover o systemd, no Debian Jessie


      Em muitos Servidores Linux, rodando a distro Debian mais recente  (Jessie), em modo texto apenas. Me deparo com um problema chato, usando os comandos halt, poweroff ou shutdown -h now, o computador desliga, mas os fam coolers não (cpu e gabinete), eles ficam rodando indefinidamente.

     A Solução encontrada foi remover o systemd e voltar para o bom e velho systemV.

     Esta é uma solução paliativa, para quem roda o Sistema apenas em modo texto, sem nenhuma interface gráfica, como Gnome,KDE, Mate, Cinnamom, Xfce, num Firewall de rede por exemplo.

     O systemd é responsável por todas as rotinas de inicialização do Sistema, além de incorporar outros recursos importantes. O SysV (system five), proveniente do Unix, é bem mais antigo, porém simples e eficiente. 
    
     Como proceder a mudança, abra o Shell e rode os seguintes comandos:


# apt-get update

# apt-get install sysvinit-core sysvinit-utils

Copiar o inittab para o diretório /etc

# cp /usr/share/sysvinit/inittab /etc/inittab
 
Para remover o systemd

# apt-get remove --purge --auto-remove systemd
 
# reboot
 
Para evitar os updates do systemd
 
# apt-mark hold systemd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

quinta-feira, 27 de outubro de 2016

Como criar uma Bridge no Debian

Quando se tem a necessidade de unificar várias redes (placas de redes), em uma única rede, a solução é o uso de uma Bridge. Este vídeo, mostra como configurar uma Bridge no Debian Linux:








https://youtu.be/oYDprhajTm4





quinta-feira, 7 de abril de 2016

Consulta entre Servidores Proxies


Como configurar dois Servidores Proxies, para trocarem informações entre si.


Primeiro devemos instalar o pacote squid3 nos dois Servidores (Debian e derivados):

#apt-get update
#apt-get install squid3

O arquivo principal de configuração do squid3 encontra-se em:
/etc/squid3/squid.conf

squid.conf básico:

http_port 3128

refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern .               0       20%     4320

acl manager url_regex -i ^cache_object:// +i ^https?://[^/]+/squid-internal-mgr/

acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

acl localnet src 10.0.0.0/8     # RFC 1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC 1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC 1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443         # https
acl Safe_ports port 70          # gopher
acl Safe_ports port 210         # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling http
acl CONNECT method CONNECT

http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access allow localnet
http_access deny all

Para limpar o arquivo squid.conf
#echo  "" > /etc/squid3/squid.conf


Arquivo squid.conf do Servidor Proxy I:

http_port 3128
icp_port 3130

refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern .               0       20%     4320

acl manager url_regex -i ^cache_object:// +i ^https?://[^/]+/squid-internal-mgr/

acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

acl localnet src 10.0.0.0/8     # RFC 1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC 1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC 1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443         # https
acl Safe_ports port 70          # gopher
acl Safe_ports port 210         # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling http
acl CONNECT method CONNECT
 
cache_peer 192.168.1.254 sibling 3128 3130 proxy-only no-delay
log_icp_queries off


http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access allow localnet
http_access deny all


Arquivo squid.conf do Servidor proxy II:

http_port 3128
icp_port 3130

refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern .               0       20%     4320

acl manager url_regex -i ^cache_object:// +i ^https?://[^/]+/squid-internal-mgr/

acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

acl localnet src 10.0.0.0/8     # RFC 1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC 1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC 1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443         # https
acl Safe_ports port 70          # gopher
acl Safe_ports port 210         # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling http
acl CONNECT method CONNECT

cache_peer 192.168.1.1 sibling 3128 3130 proxy-only no-delay
log_icp_queries off

http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access allow localnet
http_access deny all

Complete o arquivo squid.conf conforme suas necessidades.


Regras para o iptables:

Para redirecionar todo o trafego da rede para a porta do proxy:

iptables -t nat -A PREROUTING -i $LAN -p tcp -m iprange \
--src-range 192.168.1.10-192.168.1.253 -m state --stateNEW \
--dport 80 -j REDIRECT --to-port 3128


Para liberar a porta udp somente para rede interna:

iptables -I INPUT 1 -i $WAN -p udp -m udp --dport 3130 -j DROP
iptables -I INPUT 2 -i $LAN -p udp -m udp --dport 3130 -j ACCEPT


Para configurar os computadores que passarão pelo Servidor Proxy I:




Para configurar os micros que acessam via Servidor Proxy II: