Hacer un proxy con squid con fedora 19
1.
Instalar fedora 19
2.
Una vez instalado fedora 19 vamos a trabajar en
modo grafico
3.
Antes de nada vamos a actualizar el sistema
a.
Abrir terminal
b.
Autentificarse como superusuario con la
instrucción su
c.
Yum
update –y
4.
Vamos a instalar el dhcp
a.
Abrir terminal
b.
Autentificarse como superusuario con la
instrucción su
c.
Yum
install dhcp
5.
Para configurar el dhcp
a.
Abrir terminal
b.
Autentificarse como superusuario con la
instrucción su
c.
vi
/etc/dhcp/dhcpd.conf
d.
en este
caso vamos a utilizar 2 tarjetas de red para que se distribuya el dhcp por eso
mismo hay que crear 2 sub redes
option host-name "guillermo";
option domain-name-servers 8.8.8.8;
authoritative; ddns-update-style
interim; ignore client-updates;
option domain-name-servers 8.8.8.8;
default-lease-time 600;
max-lease-time 7200; }
# compras
option domain-name-servers 8.8.8.8;
default-lease-time 600; max-lease-time
7200; }
e.
Salimos del editor vi con esc :wq para escribir
lo que acabamos de modificar
f.
Introducimos en terminal vi /etc/sysconfig/dhcpd esta
instrucción es para modificar donde va a dar el dhcp
g.
Nos aparecerá dhcpdargs=
h.
En nuestro caso estamos dando red por p3p1 y p34p1
i.
Y ponemos dhcpdargs= p3p1 p34p1
j.
Damos esc :wq
k.
Introducimos en terminal vi /etc/sysctl.conf esta instrucción es para modificar donde el
forwarding
l.
Nos aseguramos que este esta instrccion net.ipv4.ip_forward =1
m.
Damos esc :wq
n.
Y activamos cambios
o.
sysctl –p
6.
ahora vamos a asignarle una ip estatica a las
tarjetas de red
a.
via grafica
i.
entrar a configuración de red
ii.
ir a tarjeta de subredes
iii.
ponerle en configuración
iv.
ipv4 direcciones manual
v.
asignarle dirección ip en nuestro caso asignamos
a p3p1 192.168.2.1 y a p34p1 192.168.3.1 con mascara de red de 24 y la puerta
de enlace la tarjeta donde se sale a intenet en nuestro caso 192.168.1.92
b.
via terminal
i.
cd /etc/sysconfig/networ-scripts
ii.
vi ifcfg-Wired_connection_1 nota: si no existe este script introducir
ls y ver que archivo es parecido puede estar en español
iii.
IPADDR0=<IP que queramos configurar>
PREFIX0=24
GATEWAY0=<IP de la puerta de
enlace>
DNS1=<IP de DNS>
DNS2=<IP de otro DNS>
DEFROUTE=yes
iv.
Damos esc :wq
7.
Configurar squid
a.
Autentificarse como su en terminal
b.
Vi
/etc/squid/squi.conf
#ecommended minimum configuration: ie_refresh on offline_mode
on
# dns_v4_first on # Example rule allowing access from
your local networks. # Adapt to list your (internal) IP networks from where
browsing # should be allowed acl localnet src 10.0.0.0/8 # RFC1918 possible internal network acl localnet src 172.16.0.0/12 #
RFC1918 possible internal network acl localnet src 192.168.0.0/16 #
RFC1918 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 https port 443 http_access allow https 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
# Deny requests to certain unsafe ports
http_access deny !Safe_ports
# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports
# We strongly recommend the following be uncommented
to protect innocent # web applications running on the proxy server who think
the only # one who can access services on "localhost" is a local user
#http_access deny to_localhost
# # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM
YOUR CLIENTS #
# Example rule allowing access from your local
networks. # Adapt localnet in the ACL section to list your (internal) IP
networks # from where browsing should be allowed http_access allow localnet
http_access allow localhost
# And finally deny all other access to this proxy
http_access deny all
# Squid normally listens to port 3128 http_port 3128
transparent http_port 3128
#Uncomment and adjust the following to add a disk
cache directory. cache_dir ufs /var/spool/squid 10 16 256 cache_mem 16 MB #
Leave coredumps in the first cache dir coredump_dir /var/spool/squid
# Add any of your own refresh_pattern entries above
these. 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
cache_effective_user squid cache_effective_group squid always_direct allow all
https_port 3128 intercept
i.
Inicar
squid /bin/systemctl start squid.service
8. Configurar ip tables
iptables -F iptables -t nat –F
iptables -P
INPUT ACCEPT
iptables -P
OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
Ahora
con iptables vació y aceptando conexiones hacemos el enmascaramiento de la red
con:
iptables -t nat -A PREROUTING -i p1p1 -p tcp --dport
80 -j REDIRECT --to-port 3128 iptables -t nat -A PREROUTING -i p3p1 -p tcp
--dport 80 -j REDIRECT --to-port 3128 iptables -t nat -A PREROUTING -i p34p1 -p
tcp --dport 80 -j REDIRECT --to-port 3128
guardamos
los cambios en iptables con :
service
iptables sabe
ahora
procedemos a levantar nuestros servicios
chkconfig dhcpd on chkconfig iptables on
REALIZADO POR
GUILLERMO MUÑOZ MACIAS
EDUARDO ARTURO LEAL ZAVALA
CARLOS RAFAEL VERA NUÑEZ
HIRAM CASTAÑEDA CORONEL