Enviada: Qua Abr 05, 2006 1:06 pm Assunto: montar uma rede Linux
É o seguite gostaria de configurar uma rede linux com os seguintes componetes : um modem adsl dsl502GII - DLINK com uma conexão 400 e ip fixo, uma máquina que será o firewall/proxy, outra sera o www, outra o e-mail, e aida terei um servidor LTSP e tudo rodando FC4
1) como devo configurar o modem;
2)como deve ficar o endereço ip da rede e de cada equipamento;
3)Servidor firewall/proxy;
4)Servidor www;
5)Servidor e-mail;
6)servidor Ltsp;
Minha intenção e montar um manual (aqui no fórum) completo para quem deseja montar uma rede linux. Na internet so encontramos artigos que falam apenas de partes isoladas e assumindo que estamos todos no mesmo nível!
echo -n "checando configuração...."
if [ "$USE_MASQ" = "TRUE" ] && ! [ "$USE_SNAT" = "" ] ; then
echo
echo "ERRO NA CONFIGURAÇÃO: MASCARAMENTO OU NAT NAO ENCONTRADO!"
exit 1
fi
if [ "$INET_IFACE" = "$LAN_IFACE" ] ; then
if [ "$USE_MASQ" = "TRUE" ] || [ "$USE_SNAT" != "" ] ; then
echo
echo "ERRO NA CONFIGURAÇÃO: não foi encontrado mascara na rede ou SNAT!"
exit 1
fi
fi
if ! [ -x $IPTABLES ] ; then
echo
echo "ERROR IN CONFIGURATION: IPTABLES executável não encontrado!"
exit 1
fi
echo "teste ok"
for subnet in ${INTERNAL_LAN} ; do
${IPTABLES} -t filter -A FORWARD -s ${subnet} -j ACCEPT
${IPTABLES} -t filter -A FORWARD -d ${subnet} -j ACCEPT
echo -n "${subnet}:ACCEPT "
done
echo
#NAT
if [ $USE_MASQ = TRUE ] ; then
echo -n "Setting up NAT: "
if [ "$MAC_LAN" = "" ] ; then
for subnet in ${INTERNAL_LAN} ; do
${IPTABLES} -t nat -A POSTROUTING -s ${subnet} -o ${INET_IFACE} -j MASQUERADE
echo -n "${subnet}:MASQUERADE "
done
else
for address in ${MAC_LAN} ; do
${IPTABLES} -t nat -A POSTROUTING -m mac --mac-source ${address} -o ${INET_IFACE} -j MASQUERADE
echo -n "${address}:MASQUERADE "
done
fi
echo
elif [ "$USE_SNAT" != "" ] ; then
echo -n "Setting up NAT: "
if [ "$MAC_LAN" = "" ] ; then
for subnet in ${INTERNAL_LAN} ; do
${IPTABLES} -t nat -A POSTROUTING -s ${subnet} -o ${INET_IFACE} -j SNAT --to-source ${USE_SNAT}
echo -n "${subnet}:SNAT "
done
else
for address in ${MAC_LAN} ; do
${IPTABLES} -t nat -A POSTROUTING -m mac --mac-source ${address} -o ${INET_IFACE} -j SNAT --to-source ${USE_SNAT}
echo -n "${address}:SNAT "
done
fi
echo
fi
#TCP Port-Forwards
if [ "$TCP_FW" != "" ] ; then
echo -n "TCP Port Forwards: "
if [ "$USE_SNAT" != "" ] || [ $USE_MASQ = TRUE ] ; then
for rule in ${TCP_FW} ; do
ports=`echo $rule | sed 's/>.*//g'`
srcport=`echo $ports | sed 's/:.*//g'`
destport=`echo $ports | sed 's/.*://g'`
host=`echo $rule | sed 's/.*>//g'`
${IPTABLES} -t nat -A PREROUTING -p tcp -i ${INET_IFACE} --dport ${srcport} -j DNAT --to ${host}:${destport}
echo -n "${rule} "
done
else
for rule in ${TCP_FW} ; do
ports=`echo $rule | sed 's/>.*//g'`
srcport=`echo $ports | sed 's/:.*//g'`
destport=`echo $ports | sed 's/.*://g'`
host=`echo $rule | sed 's/.*>//g'`
${IPTABLES} -t nat -A PREROUTING -i ${INET_IFACE} -p tcp --dport ${srcport} -j REDIRECT --to ${host}:${destport}
echo -n "${rule} "
done
fi
echo
fi
#UDP Port Forwards
if [ "$UDP_FW" != "" ] ; then
echo -n "UDP Port Forwards: "
if [ "$USE_SNAT" != "" ] || [ $USE_MASQ = TRUE ] ; then
for rule in ${UDP_FW} ; do
iptables -A INPUT -p tcp --destination-port 80 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 443 -j ACCEPT ports=`echo $rule | sed 's/>.*//g'`
srcport=`echo $ports | sed 's/:.*//g'`
destport=`echo $ports | sed 's/.*://g'`
host=`echo $rule | sed 's/.*>//g'`
${IPTABLES} -t nat -A PREROUTING -p udp -i ${INET_IFACE} --dport ${srcport} -j DNAT --to ${host}:${destport}
echo -n "${rule} "
done
else
for rule in ${UDP_FW} ; do
ports=`echo $rule | sed 's/>.*//g'`
srcport=`echo $ports | sed 's/:.*//g'`
destport=`echo $ports | sed 's/.*://g'`
host=`echo $rule | sed 's/.*>//g'`
${IPTABLES} -t nat -A PREROUTING -i ${INET_IFACE} -p udp --dport ${srcport} -j REDIRECT --to ${host}:${destport}
echo -n "${rule} "
done
fi
echo
fi
if [ "$DENY_ALL" != "" ] ; then
echo -n "Denying hosts: "
for host in ${DENY_ALL} ; do
${IPTABLES} -t filter -A INETIN -s ${host} -j ${DROP}
echo -n "${host}:${DROP}"
done
echo
fi
#PACOTES INVALIDOS
echo -n "${DROP}ing pacotes invalidos..."
${IPTABLES} -t filter -A INETIN -m state --state INVALID -j ${DROP}
echo "done"
if [ "$TCP_ALLOW" != "" ] ; then
echo -n "TCP Input Allow: "
for port in ${TCP_ALLOW} ; do
if [ "0$port" == "021" ]; then
${IPTABLES} -t filter -A INETIN -p tcp --sport 20 --dport 1024:65535 ! --syn -j TCPACCEPT
fi
${IPTABLES} -t filter -A INETIN -p tcp --dport ${port} -j TCPACCEPT
echo -n "${port} "
done
echo
fi
if [ "$UDP_ALLOW" != "" ] ; then
echo -n "UDP Input Allow: "
for port in ${UDP_ALLOW} ; do
${IPTABLES} -t filter -A INETIN -p udp --dport ${port} -j UDPACCEPT
echo -n "${port} "
done
echo
fi
if [ "$DNS" != "" ] ; then
echo -n "DNS Zone Transfers: "
for server in ${DNS} ; do
${IPTABLES} -t filter -A INETIN -p udp -s ${server} --sport 53 -j UDPACCEPT
echo -n "${server} "
done
echo
fi
#SSH Rulesets
if [ $USE_SSH1 = TRUE ] || [ $USE_OPENSSH = TRUE ]; then
echo -n "Accounting for SSH..."
if [ $USE_SSH1 = TRUE ]; then #SSH1
${IPTABLES} -t filter -A INETIN -p tcp --sport 22 --dport 513:1023 ! --syn -j TCPACCEPT
echo -n "SSH1 "
fi
if [ $USE_OPENSSH = TRUE ] ; then #OpenSSH
${IPTABLES} -t filter -A INETIN -p tcp --sport 22 --dport 1024:65535 ! --syn -j TCPACCEPT
echo -n "OpenSSH "
fi
echo
fi
#AUTH(identd) host-based allows
if [ "$AUTH_ALLOW" != "" ] ; then
echo -n "AUTH accepts: "
for host in ${AUTH_ALLOW} ; do
${IPTABLES} -t filter -A INETIN -p tcp -s ${host} --dport 113 -j TCPACCEPT
echo -n "${host} "
done
echo
fi
echo -n "MANTENDO CONEXOES JA EXISTENTES..."
${IPTABLES} -t filter -A INETIN -m state --state ESTABLISHED,RELATED -j ACCEPT
echo "done"
quando vc instala ele jah vai configurado pra resolver nomes entao nao precisa mexer, se for hostar sites jah eh mais complicado pq envolve named.conf e outros arquivos.
lembrando que nas maquinas tem que ser setado nas configurações do navegador o proxy que neste caso eh
IP : 192.168.0.1 porta 3128
bom se tudo correu bem seu servidor jah esta com proxy on, compartilhando internet, resolvendo nomes, e com firewall.
bom por hoje nao posso continuar pois tenho que sair mas amanha dou continuidade neste assunto lembrando que to partindo do principio que o usuario saiba instalar os serviços na maquina.
Registrado em: Oct 22, 2004 Mensagens: 2143 Localização: Salvador - Bahia
Enviada: Qua Abr 05, 2006 5:46 pm Assunto:
Hehehehe sem palavras. _________________ Cristiano Furtado dos Santos
Gerente de Projetos de SL
Embaixador do Projeto Fedora Brasil.
Pagina Pessoal: http://jasonnfedora.eti.br
Enviada: Qui Abr 06, 2006 5:38 pm Assunto: puts!!!
Kracas agora até eu consigo montar um server assim depois desse passo a passo nuossa parabéns Dinho valews a comunidade orgulha-se....
isso que é barba, cabelo e bigode!!! _________________ Agora lembre-se que se este post estiver resolvido edite o título e adicione a tag
[RESOLVIDO]
agradeço ao pessoal pelos elogios , sou novato aqui no forum mas pretendo contribuir mas ainda e aprender mais ainda pq cada caso eh um caso e sempre tem algo pra se aprender e ajudar tb não custa nada se a galera soubesse que se aprende ajudando teriamos muito mas avanços.
continuando esse tópico vamos configurar agora o pure-ftp com mysql, por que com my sql, para aumentar a segurança de acesso dos usuarios ao ftp, pois não há nescecidade de criar usuarios locais no servidor e para administração eh muito mais fácil pondendo se criar até uma interface de administração de usuarios em php com interface para web. alias eu ainda nao criei isso pq sou uma negação e php mas convidos os programadores em php a desenvolverem uma interface que pegue os usuarios do mysql do pure-ftp e gere uma tela de adminstração intuitiva para usuarios leigos (cabeçudos). r. brincadeira em galera.
vamos lah
1º - Instale o Pure-ftpd
mas uma vez vou partir do principio que o camarada ai jah tenha instalado.
obs: paras os cabeçudos que utilizam interface grafica tem uma ferramentinha chamada yumex que eh uma mão na roda eh como se fosse um adcionar e remover programas soh que com a funcionalidade do yum ou seja digita o nome do pacote que quer e ele te lista dai eh soh selecionar e instalar.
#No mysql :
se vc jah tiver instalado o MySql e jah tenha configurado o root blz mas se nao use esse comando aqui depois de instalar o mySql, nao vou entrar na instalação do mysql pq tem n variações.
obs: pode dar alguns erros pq cada distro ta configurada de um jeito o meu deu que o grupo ja existia mas ignorei o erro e prosegui e no final tudo funcionou. mas como o famosa peça que todos os computadores possuem chamada burrinhodoteclado da problema, sempre temos algum pepino.
#No mysql
############################################
mysql -u root -p
CREATE DATABASE pureftpd;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO 'pureftpd'@'localhost' IDENTIFIED BY 'senhadoftp';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO 'pureftpd'@'localhost.localdomain' IDENTIFIED BY 'senhadoftp';
FLUSH PRIVILEGES;
#############################################
se quiser copiar e colar tudo no console acho que funciona
criando a tabela de usuarios
#############################################
USE pureftpd;
#############################################
CREATE TABLE ftpd (
User varchar(16) NOT NULL default '',
status enum('0','1') NOT NULL default '0',
Password varchar(64) NOT NULL default '',
Uid varchar(11) NOT NULL default '-1',
Gid varchar(11) NOT NULL default '-1',
Dir varchar(128) NOT NULL default '',
ULBandwidth smallint(5) NOT NULL default '0',
DLBandwidth smallint(5) NOT NULL default '0',
comment tinytext NOT NULL,
ipaccess varchar(15) NOT NULL default '*',
QuotaSize smallint(5) NOT NULL default '0',
QuotaFiles int(11) NOT NULL default 0,
PRIMARY KEY (User),
UNIQUE KEY User (User)
) TYPE=MyISAM;
# If you want to run Pure-FTPd with this configuration
# instead of command-line options, please run the
# following command :
#
# /usr/sbin/pure-config.pl /etc/pure-ftpd/pure-ftpd.conf
#
# Please don't forget to have a look at documentation at
# http://www.pureftpd.org/documentation.shtml for a complete list of
# options.
# Cage in every user in his home directory
ChrootEveryone yes
# If the previous option is set to "no", members of the following group
# won't be caged. Others will be. If you don't want chroot()ing anyone,
# just comment out ChrootEveryone and TrustedGID.
# TrustedGID 100
# Turn on compatibility hacks for broken clients
BrokenClientsCompatibility no
# Maximum number of simultaneous users
MaxClientsNumber 50
# Fork in background
Daemonize yes
# Maximum number of sim clients with the same IP address
MaxClientsPerIP 8
# If you want to log all client commands, set this to "yes".
# This directive can be duplicated to also log server responses.
VerboseLog no
# List dot-files even when the client doesn't send "-a".
DisplayDotFiles yes
# Don't allow authenticated users - have a public anonymous FTP only.
AnonymousOnly no
# Disallow anonymous connections. Only allow authenticated users.
NoAnonymous no
# Syslog facility (auth, authpriv, daemon, ftp, security, user, local*)
# The default facility is "ftp". "none" disables logging.
SyslogFacility ftp
# Display fortune cookies
# FortunesFile /usr/share/fortune/zippy
# Don't resolve host names in log files. Logs are less verbose, but
# it uses less bandwidth. Set this to "yes" on very busy servers or
# if you don't have a working DNS.
DontResolve yes
# Maximum idle time in minutes (default = 15 minutes)
# Path to pure-authd socket (see README.Authentication-Modules)
# ExtAuth /var/run/ftpd.sock
# If you want to enable PAM authentication, uncomment the following line
PAMAuthentication yes
# If you want simple Unix (/etc/passwd) authentication, uncomment this
# UnixAuthentication yes
# Please note that LDAPConfigFile, MySQLConfigFile, PAMAuthentication and
# UnixAuthentication can be used only once, but they can be combined
# together. For instance, if you use MySQLConfigFile, then UnixAuthentication,
# the SQL server will be asked. If the SQL authentication fails because the
# user wasn't found, another try # will be done with /etc/passwd and
# /etc/shadow. If the SQL authentication fails because the password was wrong,
# the authentication chain stops here. Authentication methods are chained in
# the order they are given.
# 'ls' recursion limits. The first argument is the maximum number of
# files to be displayed. The second one is the max subdirectories depth
LimitRecursion 7500 8
# Are anonymous users allowed to create new directories ?
AnonymousCanCreateDirs no
# If the system is more loaded than the following value,
# anonymous users aren't allowed to download.
MaxLoad 4
# Port range for passive connections replies. - for firewalling.
# PassivePortRange 30000 50000
# Force an IP address in PASV/EPSV/SPSV replies. - for NAT.
# Symbolic host names are also accepted for gateways with dynamic IP
# addresses.
# ForcePassiveIP 192.168.0.1
# Upload/download ratio for anonymous users.
# AnonymousRatio 1 10
# Upload/download ratio for all users.
# This directive superscedes the previous one.
# UserRatio 1 10
# Disallow downloading of files owned by "ftp", ie.
# files that were uploaded but not validated by a local admin.
AntiWarez yes
# IP address/port to listen to (default=all IP and port 21).
# Bind 127.0.0.1,21
# Maximum bandwidth for anonymous users in KB/s
# AnonymousBandwidth 8
# Maximum bandwidth for *all* users (including anonymous) in KB/s
# Use AnonymousBandwidth *or* UserBandwidth, both makes no sense.
# UserBandwidth 8
# File creation mask. <umask for files>:<umask for dirs> .
# 177:077 if you feel paranoid.
Umask 133:022
# Minimum UID for an authenticated user to log in.
MinUID 500
# Allow FXP transfers for authenticated users.
AllowUserFXP no
# Allow anonymous FXP for anonymous and non-anonymous users.
AllowAnonymousFXP no
# Users can't delete/write files beginning with a dot ('.')
# even if they own them. If TrustedGID is enabled, this group
# will have access to dot-files, though.
ProhibitDotFilesWrite no
# Prohibit *reading* of files beginning with a dot (.history, .ssh...)
ProhibitDotFilesRead no
# Never overwrite files. When a file whoose name already exist is uploaded,
# it get automatically renamed to file.1, file.2, file.3, ...
AutoRename no
# Disallow anonymous users to upload new files (no = upload is allowed)
AnonymousCantUpload yes
# Only connections to this specific IP address are allowed to be
# non-anonymous. You can use this directive to open several public IPs for
# anonymous FTP, and keep a private firewalled IP for remote administration.
# You can also only allow a non-routable local IP (like 10.x.x.x) to
# authenticate, and keep a public anon-only FTP server on another IP.
#TrustedIP 10.1.1.1
# If you want to add the PID to every logged line, uncomment the following
# line.
#LogPID yes
# Create an additional log file with transfers logged in a Apache-like format :
# fw.c9x.org - jedi [13/Dec/1975:19:36:39] "GET /ftp/linux.tar.bz2" 200 21809338
# This log file can then be processed by www traffic analyzers.
AltLog clf:/var/log/pureftpd.log
# Create an additional log file with transfers logged in a format optimized
# for statistic reports.
# AltLog stats:/var/log/pureftpd.log
# Create an additional log file with transfers logged in the standard W3C
# format (compatible with most commercial log analyzers)
# AltLog w3c:/var/log/pureftpd.log
# Disallow the CHMOD command. Users can't change perms of their files.
#NoChmod yes
# Allow users to resume and upload files, but *NOT* to delete them.
#KeepAllFiles yes
# Automatically create home directories if they are missing
#CreateHomeDir yes
# Enable virtual quotas. The first number is the max number of files.
# The second number is the max size of megabytes.
# So 1000:10 limits every user to 1000 files and 10 Mb.
#Quota 1000:10
# If your pure-ftpd has been compiled with standalone support, you can change
# the location of the pid file. The default is /var/run/pure-ftpd.pid
#PIDFile /var/run/pure-ftpd.pid
# If your pure-ftpd has been compiled with pure-uploadscript support,
# this will make pure-ftpd write info about new uploads to
# /var/run/pure-ftpd.upload.pipe so pure-uploadscript can read it and
# spawn a script to handle the upload.
#CallUploadScript yes
# This option is useful with servers where anonymous upload is
# allowed. As /var/ftp is in /var, it save some space and protect
# the log files. When the partition is more that X percent full,
# new uploads are disallowed.
MaxDiskUsage 99
# Set to 'yes' if you don't want your users to rename files.
#NoRename yes
# Be 'customer proof' : workaround against common customer mistakes like
# 'chmod 0 public_html', that are valid, but that could cause ignorant
# customers to lock their files, and then keep your technical support busy
# with silly issues. If you're sure all your users have some basic Unix
# knowledge, this feature is useless. If you're a hosting service, enable it.
CustomerProof yes
# Per-user concurrency limits. It will only work if the FTP server has
# been compiled with --with-peruserlimits (and this is the case on
# most binary distributions) .
# The format is : <max sessions per user>:<max anonymous sessions>
# For instance, 3:20 means that the same authenticated user can have 3 active
# sessions max. And there are 20 anonymous sessions max.
# PerUserLimits 3:20
# When a file is uploaded and there is already a previous version of the file
# with the same name, the old file will neither get removed nor truncated.
# Upload will take place in a temporary file and once the upload is complete,
# the switch to the new version will be atomic. For instance, when a large PHP
# script is being uploaded, the web server will still serve the old version and
# immediatly switch to the new one as soon as the full file will have been
# transfered. This option is incompatible with virtual quotas.
# NoTruncate yes
# This option can accept three values :
# 0 : disable SSL/TLS encryption layer (default).
# 1 : accept both traditional and encrypted sessions.
# 2 : refuse connections that don't use SSL/TLS security mechanisms,
# including anonymous sessions.
# Do _not_ uncomment this blindly. Be sure that :
# 1) Your server has been compiled with SSL/TLS support (--with-tls),
# 2) A valid certificate is in place,
# 3) Only compatible clients will log in.
# TLS 1
# Listen only to IPv4 addresses in standalone mode (ie. disable IPv6)
# By default, both IPv4 and IPv6 are enabled.
# IPV4Only yes
# Listen only to IPv6 addresses in standalone mode (ie. disable IPv4)
# By default, both IPv4 and IPv6 are enabled.
# IPV6Only yes
# Do not use the /etc/ftpusers file to disable accounts. We're already
# using MinUID to block users with uid < 500
MYSQLPassword senhadoftp #aqui eh a senha que vc configurou no mysql do banco
MYSQLDatabase pureftpd
#MYSQLCrypt md5, cleartext, crypt() or password() - md5 is VERY RECOMMENDABLE uppon cleartext
MYSQLCrypt md5
MYSQLGetPW SELECT Password FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MYSQLGetUID SELECT Uid FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MYSQLGetGID SELECT Gid FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MYSQLGetDir SELECT Dir FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetBandwidthUL SELECT ULBandwidth FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetBandwidthDL SELECT DLBandwidth FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetQTASZ SELECT QuotaSize FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetQTAFS SELECT QuotaFiles FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
#############################################
#############################################
#############################################
verifique esse arquivo aqui
/etc/pure-ftpd/conf/ChrootEveryone
veja se contem yes na primeira linha
caso não adicione yes
mesma coisa aqui /etc/pure-ftpd/conf/CreateHomeDir
lembrando que aqui no final do aquivo '25', '25', '', '*', '50',
significa 25 k de download depis 25k de upload e 50 equivale a cota de disco do usuario.
/var/www/html/pastadousuario
isto eh a pasta do usuario que esta sendo criado.
pra adcionar outro usuario eh soh repetir o comando e modificar
prontinho se tudo correu bem agora u seu ftp ta usando o mysql como banco de usuarios e com controle de banda. e o mais importante segurança.
valeuuu rapaziada ..................
qualquer duvida estamos ai, e outra acho que nao esqueci de nada mas podem me corrigir se es estiver errado galera estamos aqui pra aprender.
cara soh basta mudar o ip da internet no firewall, por isso criei com variaveis pra facilitar, e se quiser personalizar as paradas eh soh ir adcionando ou removendo os codigos de cada configuração nos arquivos.