+ Responder ao Tópico



  1. #1

    Question Mascaramento por ips varias sub-redes não vai.

    Tenho o seguinte esquema :

    No caso esta esta /24 255.255.255.0 e não funciona.

    iptables -t nat -A POSTROUTING -s 192.168.70.16 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.23 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.30 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.31 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.32 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.33 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.34 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.35 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.36 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.37 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.38 -o ppp0 -j MASQUERADE

    Esta esta dividida em sub redes /30 255.255.255.252

    iptables -t nat -A POSTROUTING -s 198.169.0.2 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 198.169.1.2 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 198.169.2.2 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 198.169.3.2 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 198.169.4.2 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 198.169.5.2 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 198.169.6.2 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 198.169.7.2 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 198.169.8.2 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 198.169.9.2 -o ppp0 -j MASQUERADE

    E não navega, estou sem o squid para testar e não vai . com o squid so funciona no navegador, porque não esta fazendo o mascaramento ?

    Deste jeito funciona a rede /24 255.255.255.0

    echo 1 > /proc/sys/net/ipv4/ip_forward
    iptables -t nat -A POSTROUTING -s 192.168.70.0/24 -j MASQUERADE
    iptables -A FORWARD -s 192.168.70.0/24 -j ACCEPT
    iptables -A FORWARD -i ppp0 -j ACCEPT
    iptables -A FORWARD -i eth0 -j ACCEPT
    iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT


    O que pode ser ?

  2. #2

    Padrão

    será que pode ser o fato dos ip aliases ?

    Estou levantando eles no scripts assim:
    A eth0 é 192.168.70.1/24

    ifconfig eth0:0 200.169.0.1 netmask 255.255.255.252
    ifconfig eth0:1 200.169.1.1 netmask 255.255.255.252
    ifconfig eth0:2 200.169.2.1 netmask 255.255.255.252
    ifconfig eth0:3 200.169.3.1 netmask 255.255.255.252
    ifconfig eth0:4 200.169.4.1 netmask 255.255.255.252
    ifconfig eth0:5 200.169.5.1 netmask 255.255.255.252
    ifconfig eth0:6 200.169.6.1 netmask 255.255.255.252
    ifconfig eth0:7 200.169.7.1 netmask 255.255.255.252
    ifconfig eth0:8 200.169.8.1 netmask 255.255.255.252
    ifconfig eth0:9 200.169.9.1 netmask 255.255.255.252

    depois uso

    iptables -t nat -A POSTROUTING -s 192.168.70.16 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.23 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.30 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.31 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.32 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.33 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.34 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.35 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.36 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.37 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 192.168.70.38 -o ppp0 -j MASQUERADE

    Esta esta dividida em sub redes /30 255.255.255.252

    iptables -t nat -A POSTROUTING -s 200.169.0.2 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 200.169.1.2 -o ppp0 -j MASQUERADE
    iptables -t nat -A POSTROUTING -s 200.169.2.2 -o ppp0 -j MASQUERADE

    e assim vai. mas não vai mesmo. estou com debian.