portail_captif: disclaimer http sur vlan 10
Cela fait popper une page web (proxy transparent) sur laquelle les clients CROUS sont invités à venir adhérer. Ils peuvent néanmoins continuer à naviguer en cliquant sur un lien qui rajoute leur IP à une liste d'IP whitelistées du firewall. Penser à désactiver le keep-alive du serveur web/proxy (nginx) car sinon, on constate des trucs marrants. (Normal, le -j DNAT n'a d'effet que lors de l'établissement de la connexion). PS: détabification massive du fichier portail_captif.py (pardon aux familles)
This commit is contained in:
parent
b843c80153
commit
b86aca109f
3 changed files with 161 additions and 122 deletions
|
@ -15,10 +15,21 @@ iptables -t mangle -F
|
|||
ip6tables -t mangle -F
|
||||
ip6tables -F
|
||||
|
||||
|
||||
iptables -t raw -A PREROUTING -d 224.0.0.0/4 -j DROP
|
||||
# On log les les paquets
|
||||
iptables -t mangle -A PREROUTING -i eth1 -m state --state NEW -j LOG --log-prefix "LOG_ALL "
|
||||
iptables -t mangle -A PREROUTING -i eth0 -m state --state NEW -j LOG --log-prefix "LOG_ALL "
|
||||
|
||||
# <Portail captif>
|
||||
ipset -q create allowed_guests bitmap:ip range 10.231.137.0/24 || ipset flush allowed_guests
|
||||
iptables -t nat -N CAPTIF 2> /dev/null || iptables -t nat -F CAPTIF
|
||||
#iptables -t nat -A PREROUTING --src 10.231.137.189 -j CAPTIF
|
||||
iptables -t nat -A PREROUTING -j CAPTIF
|
||||
iptables -t nat -A CAPTIF -p tcp --dport 80 -m set \! --match-set allowed_guests src -j DNAT --to-destination 10.231.137.1
|
||||
iptables -t nat -A CAPTIF -j RETURN
|
||||
# </Portail captif>
|
||||
|
||||
# On nat l'ipv4
|
||||
iptables -t nat -A POSTROUTING -j MASQUERADE
|
||||
|
||||
|
@ -53,4 +64,4 @@ echo 1 > /proc/sys/net/ipv4/conf/eth0/forwarding
|
|||
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
|
||||
|
||||
# On lance radvd
|
||||
/etc/init.d/radvd start
|
||||
#/etc/init.d/radvd start
|
||||
|
|
6
utils/install-party/ipset_allow
Executable file
6
utils/install-party/ipset_allow
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
#echo "$1" | grep -q "^\([0-9]\)*\.\([0-9]\)*\.\([0-9]\)*\.\([0-9]\)*$" || exit 42
|
||||
echo "$1" | grep -q "^10\.231\.137\.\([0-9]\)*$" || exit 42
|
||||
|
||||
/usr/sbin/ipset add allowed_guests $1
|
|
@ -30,6 +30,9 @@ deco={
|
|||
'non_inscrit': 'ERR_CUSTOM_NON_INSCRIT.html',
|
||||
'inscrit': 'ERR_CUSTOM_INSCRIT.html',
|
||||
|
||||
'ex_crous': 'ERR_CUSTOM_EX_CROUS.html',
|
||||
'ex_crous_enable': 'ERR_CUSTOM_EX_CROUS_ENABLE.html',
|
||||
|
||||
'age': 'ERR_CUSTOM_AGE.html',
|
||||
'ago': 'ERR_CUSTOM_AGO.html',
|
||||
|
||||
|
@ -78,6 +81,19 @@ def mac_from_ip(ip):
|
|||
else:
|
||||
return None
|
||||
|
||||
def enable_access(ip):
|
||||
"""Lance la commande idoine pour autoriser l'adresse IP"""
|
||||
p = subprocess.Popen(['sudo', '-n', '/usr/scripts/utils/install-party/ipset_allow', ip],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
out, err = p.communicate()
|
||||
if out or err:
|
||||
print "ipset_allow:"
|
||||
print out
|
||||
print "---"
|
||||
print err
|
||||
return False
|
||||
return True
|
||||
|
||||
def get(str):
|
||||
global QUERY
|
||||
|
@ -126,7 +142,13 @@ def app(environ, start_response):
|
|||
ip=environ['HTTP_REAL_IP']
|
||||
now=time.time()
|
||||
cleanup(now)
|
||||
if ip in cache.keys() and cache[ip]['time']>(now - cache_time):
|
||||
if AddrInNet(ip, '10.231.137.0/24'):
|
||||
if environ.get('RAW_URI', '').startswith('/enable'):
|
||||
enable_access(ip)
|
||||
data = deco['ex_crous_enable']
|
||||
else:
|
||||
data = deco['ex_crous']
|
||||
elif ip in cache.keys() and cache[ip]['time']>(now - cache_time):
|
||||
data=cache[ip]['page']
|
||||
else:
|
||||
if AddrInNet(ip,'10.51.0.0/16'):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue