Indice   FAQ  
Iscriviti  Login
Indice RouterOS RouterOS

Subnet utente guest, lan e wifi

Tutto su questo sistema operativo linux based - Configurazioni, dubbi, problematiche &....

Subnet utente guest, lan e wifi

Messaggioda stef84 » mar 1 dic 2015, 13:18

Buon giorno a tutti. Avrei una necessità particolare su un RB951-2n.

In pratica, dovrei usarla come Acces point + Switch sulle porte 2-3-4-5, mentre sulla porta 1 creare una diversa subnet "GUEST" (con dhcp-server su, ad esempio, 10.10.0.x), dove agli user collegati su quella LAN non possono accedere alla subnet principale, non possono vedere ne modificare nulla, ma solamente navigare in internet (quindi lasciare aperte solo porte http e https).

Inoltre, i medesimi utenti guest dovrebbero avere accesso in wifi, con SSID "ospite" e wpa2 che andrei a modificare periodicamente.

Questo lavoro già l'ho fatto su un apparato Tplink con Openwrt, dove la porta WAN fungeva da guest, la seconda interfaccia wifi era bridgiata alla porta WAN e a tutti gli utenti guest (sia lan che wifi) gli veniva assegnato IP dal dhcp-server su 10.10.0.X.

Posto in allegato la config che usavo su openwrt, magari può tornare utile.

Ringrazio di cuore anticipatamente chiunque mi sappia dare uan mano, io ho provato a segurie una falsa riga di questa configurazione ma purtroppo non ne ho ricavato nulla.

Grazie a tutti.

firewall
Codice: Seleziona tutto

config defaults
   option syn_flood '1'
   option input 'ACCEPT'
   option output 'ACCEPT'
   option forward 'REJECT'


config zone
   option name 'wan'
   option input 'ACCEPT'
   option output 'ACCEPT'
   option forward 'ACCEPT'
   option masq '1'
   option mtu_fix '1'
   option network 'lan'


config rule
   option name 'Allow-DHCP-Renew'
   option src 'wan'
   option proto 'udp'
   option dest_port '68'
   option target 'ACCEPT'
   option family 'ipv4'

config rule
   option name 'Allow-Ping'
   option src 'wan'
   option proto 'icmp'
   option icmp_type 'echo-request'
   option family 'ipv4'
   option target 'ACCEPT'

config rule
   option name 'Allow-DHCPv6'
   option src 'wan'
   option proto 'udp'
   option src_ip 'fe80::/10'
   option src_port '547'
   option dest_ip 'fe80::/10'
   option dest_port '546'
   option family 'ipv6'
   option target 'ACCEPT'

config rule
   option name 'Allow-ICMPv6-Input'
   option src 'wan'
   option proto 'icmp'
   list icmp_type 'echo-request'
   list icmp_type 'echo-reply'
   list icmp_type 'destination-unreachable'
   list icmp_type 'packet-too-big'
   list icmp_type 'time-exceeded'
   list icmp_type 'bad-header'
   list icmp_type 'unknown-header-type'
   list icmp_type 'router-solicitation'
   list icmp_type 'neighbour-solicitation'
   list icmp_type 'router-advertisement'
   list icmp_type 'neighbour-advertisement'
   option limit '1000/sec'
   option family 'ipv6'
   option target 'ACCEPT'

config rule
   option name 'Allow-ICMPv6-Forward'
   option src 'wan'
   option dest '*'
   option proto 'icmp'
   list icmp_type 'echo-request'
   list icmp_type 'echo-reply'
   list icmp_type 'destination-unreachable'
   list icmp_type 'packet-too-big'
   list icmp_type 'time-exceeded'
   list icmp_type 'bad-header'
   list icmp_type 'unknown-header-type'
   option limit '1000/sec'
   option family 'ipv6'
   option target 'ACCEPT'

config include
   option path '/etc/firewall.user'

# Regole Guest

# 4a

config 'zone'
   option name 'guest'
   option network 'guest'
   option input 'ACCEPT'
   option forward 'ACCEPT'
   option output 'ACCEPT'

# Allow Guest -> Internet
config 'forwarding'
   option src 'guest'
   option dest 'wan'

# Allow DNS Guest -> Router
# Client DNS queries ordinate from dynamic UDP ports (>1023)

config 'rule'
   option name 'Allow DNS Queries'
   option src 'guest'
   option dest_port '53'
   option proto 'tcpudp'
   option target 'ACCEPT'

# Allow DHCP Guest -> Router
# DHCP communication uses UDP ports 67-68
config 'rule'
   option name 'Allow DHCP request'
   option src 'guest'
   option src_port '67-68'
   option dest_port '67-68'
   option proto 'udp'
   option target 'ACCEPT'



config rule
   option src 'guest'
   option target 'DROP'
   option name 'Deny Access to router'

config rule
   option src 'guest'
   option dest 'wan'
   option dest_ip 192.168.1.1/24
   option name 'Deny Guest -> WAN'
   option proto 'all'
   option target 'DROP'

config rule
   option target 'ACCEPT'
   option src 'guest'
   option dest 'wan'
   option name 'Allow Guest -> WAN http'
   option proto 'tcp'
   option dest_port '80'

config rule
   option target 'ACCEPT'
   option src 'guest'
   option dest 'wan'
   option name 'Allow Guest -> WAN https'
   option proto 'tcp'
   option dest_port '443'

config rule
   option src 'guest'
   option dest 'wan'
   option name 'Deny Guest -> WAN'
   option proto 'all'
   option target 'ACCEPT'


network
Codice: Seleziona tutto
config interface 'loopback'
   option ifname 'lo'
   option proto 'static'
   option ipaddr '127.0.0.1'
   option netmask '255.0.0.0'

config globals 'globals'
option ula_prefix 'XXXX:270c:XXXX::/48'

config interface 'lan'
   option ifname 'eth1'
   option force_link '1'
   option type 'bridge'
   option proto 'static'
   option netmask '255.255.255.0'
   option dns '8.8.4.4'
   option ipaddr '192.168.1.7'
   option gateway '192.168.1.1'

config switch
   option name 'switch0'
   option reset '1'
   option enable_vlan '1'

config switch_vlan
   option device 'switch0'
   option vlan '1'
   option ports '0 2 3 4 5'

config switch_vlan
   option device 'switch0'
   option vlan '2'
   option ports '1 6'

config interface 'guest'
   option proto 'static'
   option ipaddr '10.10.0.1'
   option netmask '255.255.255.0'
   option type 'bridge'
   option ifname 'eth0'
stef84
Mikrotik-User 10° Liv
Mikrotik-User 10° Liv
 
Messaggi: 28
Iscritto il: sab 8 set 2012, 12:16
Uso routerOS dalla Versione: v5.x
Certificazioni Mikrotik: MTCNA
Preferred Training Centre: Grifonline

Re: Subnet utente guest, lan e wifi

Messaggioda xanio » mar 1 dic 2015, 23:27

Ciao,
secondo me puoi fare tutto con un apparato, quindi crei un VAP sull'interfaccia wlan1 ed assegni i dati per ESSID ospite.

Poi fai un bridge-ospite VAP + ether1 ed abiliti DHCP per la lan 10.10.10.0/24.
Poi sul bridge-lan (wlan1 + ether2, ether3,ether4,ether5) abiliti il masquarade (per la lan 10.10.10.0/24).

Poi imposta delle regole di firewall ad-hoc sulla chain forward, per le dovute regole di firewalling.
---
MTCNA - MTCRE
Avatar utente
xanio
Staff rosIT
Staff rosIT
 
Messaggi: 1054
Iscritto il: lun 31 ott 2011, 18:15
Località: Sicilia
Uso routerOS dalla Versione: v4.x
Certificazioni Mikrotik: MTCNA - MTCRE
Altre certificazioni: Milestone - Yeastar - Cambium
Preferred Training Centre: Grifonline

Re: Subnet utente guest, lan e wifi

Messaggioda stef84 » mer 2 dic 2015, 10:18

Innanzitutto ti ringrazio per l'aiuto e per le dritte.

Ho creato il bridge tra VAP+ether1, abilitato il dhcp server su 10.10.0.1 e vedo che collegandomi (sia lan che wifi) alla macchian gli viene assegnato l'IP impostato nel pool (10.10.0.100-10.10.0.110)

Ora, la nota dolente... il firewall e masquerade.

Ho provato, ma non riesco proprio a navigare sulla rete guest (sia lan che wifi)

Internet mi arriva dalla lan nel bridge wlan+ether2-master-local, da un gateway a monte che sta su 192.168.1.1

ecco un export del firewall:
Codice: Seleziona tutto
# jan/02/1970 00:34:20 by RouterOS 5.24
# software id = 5I25-A04W
#
/ip firewall connection tracking
set enabled=yes generic-timeout=10m icmp-timeout=10s tcp-close-timeout=10s \
    tcp-close-wait-timeout=10s tcp-established-timeout=1d \
    tcp-fin-wait-timeout=10s tcp-last-ack-timeout=10s \
    tcp-syn-received-timeout=5s tcp-syn-sent-timeout=5s tcp-syncookie=no \
    tcp-time-wait-timeout=10s udp-stream-timeout=3m udp-timeout=10s
/ip firewall filter
add action=accept chain=input comment="default configuration" disabled=no \
    protocol=icmp
add action=accept chain=input comment="default configuration" \
    connection-state=established disabled=no
add action=accept chain=input comment="default configuration" \
    connection-state=related disabled=no
add action=drop chain=input comment="default configuration" disabled=no \
    in-interface=ether1-guest
/ip firewall nat
add action=masquerade chain=srcnat comment="default configuration" disabled=\
    no out-interface=bridge-local
add action=masquerade chain=srcnat disabled=no src-address=10.10.0.1
/ip firewall service-port
set ftp disabled=no ports=21
set tftp disabled=no ports=69
set irc disabled=no ports=6667
set h323 disabled=no
set sip disabled=no ports=5060,5061 sip-direct-media=yes
set pptp disabled=no


Grazie ancora
stef84
Mikrotik-User 10° Liv
Mikrotik-User 10° Liv
 
Messaggi: 28
Iscritto il: sab 8 set 2012, 12:16
Uso routerOS dalla Versione: v5.x
Certificazioni Mikrotik: MTCNA
Preferred Training Centre: Grifonline

Re: Subnet utente guest, lan e wifi

Messaggioda stef84 » mer 2 dic 2015, 10:54

credo che sia meglio che allego un export completo della configurazione, altrimenti allegando solo il codice verrebbe troppo lungo e caotico da visualizzare.

Scusatemi se non sono proprio precisissimo.

Grazie ancora
Non hai i permessi necessari per visualizzare i file allegati in questo messaggio.
stef84
Mikrotik-User 10° Liv
Mikrotik-User 10° Liv
 
Messaggi: 28
Iscritto il: sab 8 set 2012, 12:16
Uso routerOS dalla Versione: v5.x
Certificazioni Mikrotik: MTCNA
Preferred Training Centre: Grifonline

Re: Subnet utente guest, lan e wifi

Messaggioda stef84 » mer 2 dic 2015, 22:58

Risolto :coolyea:

Diciamo che il problema principale era nel creare il masquerade, dove non aggiungevo x.x.x.0/24.
Inoltre, ho dovuto creare una rotta con dst 0.0.0.0/24 e gateway 192.168.1.1, senza di questo non riuscivo a navigare.
Quindi, ho deciso di cambiare ip e pool al dhcp, andando in un altra subnet, perchè casualmente la stessa la uso in un altro router e non vorrei far confusione.

Una volta verificata la navigazione su rete guest (sia lan che wifi), ho provveduto a creare le regole del firewall per impedire agli utenti guest di accedere e pingare la subnet sotto bridge-local.

Ecco un export, magari torna utile anche ad altri alle prime armi come me!

Codice: Seleziona tutto
# dec/02/2015 20:48:43 by RouterOS 5.24
# software id = 5I25-A04W
#
/interface bridge
add admin-mac=XX:XX:XX:XX:XX:XX auto-mac=no l2mtu=1598 name=bridge-local \
    protocol-mode=rstp
add l2mtu=2290 name=bridge-guest
/interface wireless
set 0 band=2ghz-b/g/n channel-width=20/40mhz-ht-above disabled=no distance=\
    indoors frequency=2437 hide-ssid=yes l2mtu=2290 mode=ap-bridge ssid=\
    WIFI wireless-protocol=any
/interface ethernet
set 0 name=ether1-guest
set 1 name=ether2-master-local
set 2 master-port=ether2-master-local name=ether3-slave-local
set 3 master-port=ether2-master-local name=ether4-slave-local
set 4 master-port=ether2-master-local name=ether5-slave-local
/interface wireless security-profiles
set [ find default=yes ] authentication-types=wpa-psk,wpa2-psk eap-methods=\
    passthrough mode=dynamic-keys supplicant-identity=MikroTik \
    wpa-pre-shared-key=password wpa2-pre-shared-key=password
add authentication-types=wpa-psk,wpa2-psk eap-methods=passthrough \
    management-protection=allowed mode=dynamic-keys name=guest \
    supplicant-identity="" wpa-pre-shared-key=00000000 wpa2-pre-shared-key=\
    00000000
/interface wireless
add area="" arp=enabled bridge-mode=enabled default-ap-tx-limit=0 \
    default-authentication=yes default-client-tx-limit=0 default-forwarding=\
    yes disable-running-check=no disabled=no hide-ssid=no l2mtu=2290 \
    mac-address=XX:XX:XX:XX:XX:XX master-interface=wlan1 max-station-count=\
    2007 mtu=1500 multicast-helper=default name=wlan-guest \
    proprietary-extensions=post-2.9.25 security-profile=guest ssid=Ospite \
    update-stats-interval=disabled wds-cost-range=0 wds-default-bridge=none \
    wds-default-cost=0 wds-ignore-ssid=no wds-mode=disabled wmm-support=\
    disabled
/ip hotspot user profile
set [ find default=yes ] idle-timeout=none keepalive-timeout=2m
/ip pool
add name=dhcp_pool3 ranges=30.30.0.100-30.30.0.120
/ip dhcp-server
add address-pool=dhcp_pool3 disabled=no interface=bridge-guest name=dhcp1
/interface bridge port
add bridge=bridge-local interface=ether2-master-local
add bridge=bridge-local interface=wlan1
add bridge=bridge-guest interface=ether1-guest
add bridge=bridge-guest interface=wlan-guest
/ip address
add address=192.168.1.244/24 comment="default configuration" interface=\
    bridge-local
add address=30.30.0.1/24 interface=bridge-guest
/ip dhcp-client
add comment="default configuration" disabled=no interface=ether1-guest
/ip dhcp-server network
add address=30.30.0.0/24 dns-server=8.8.8.8,8.8.4.4 gateway=30.30.0.1
/ip dns
set allow-remote-requests=yes
/ip dns static
add address=192.168.88.1 name=router
/ip firewall filter
add chain=input comment="default configuration" protocol=icmp
add chain=input comment="default configuration" connection-state=established
add chain=input comment="default configuration" connection-state=related
add action=drop chain=input comment="default configuration" in-interface=\
    bridge-guest
add action=drop chain=forward comment="Blocco Ospiti" dst-address=\
    30.30.0.0/24 src-address=192.168.1.0/24
add action=drop chain=forward comment="Blocco Ospiti" dst-address=\
    192.168.1.0/24 src-address=30.30.0.0/24
/ip firewall nat
add action=masquerade chain=srcnat out-interface=bridge-local
add action=masquerade chain=srcnat comment="default configuration" \
    out-interface=bridge-local src-address=30.30.0.0/24 to-addresses=0.0.0.0
/ip neighbor discovery
set ether1-guest disabled=yes
set wlan1 disabled=yes
set wlan-guest disabled=yes
/ip route
add distance=1 gateway=192.168.1.1
/system identity
set name=RB951-2n
/system leds
set 0 interface=wlan1
/system ntp client
set enabled=yes mode=unicast primary-ntp=193.204.114.232
/system routerboard settings
set cpu-frequency=400MHz
/tool mac-server
add disabled=no interface=ether2-master-local
add disabled=no interface=ether3-slave-local
add disabled=no interface=ether4-slave-local
add disabled=no interface=ether5-slave-local
add disabled=no interface=wlan1
add disabled=no interface=bridge-local
/tool mac-server mac-winbox
set [ find default=yes ] disabled=yes
add interface=ether2-master-local
add interface=ether3-slave-local
add interface=ether4-slave-local
add interface=ether5-slave-local
add interface=wlan1
add interface=bridge-local


[bye]
stef84
Mikrotik-User 10° Liv
Mikrotik-User 10° Liv
 
Messaggi: 28
Iscritto il: sab 8 set 2012, 12:16
Uso routerOS dalla Versione: v5.x
Certificazioni Mikrotik: MTCNA
Preferred Training Centre: Grifonline



Torna a RouterOS

Chi c’è in linea

Visitano il forum: Nessuno e 5 ospiti