1

Temat: reguły firewall

Do Funboxa (10.10.1.1) mam podłączone trzy routery, którym na WANie ustawiłem na sztywno kolejne adresy czyli .2 .3 .4, każdy z tych routerów ma swoją adresację typu 10.10.2.x czy 10.10.3.x. Generalnie wszystko działa, ale chciałym z sieci 10.10.2.x mieć dostęp do pozostałych sieci, ale tak żeby pozostałe sieci nie miały dostępu do tej .2, dodatkowo w sieci .1 jest drukarka do której chciałbym mieć dostęp tylko z sieci .2

Zakładam, że to jakoś muszę zrobić przekierowaniami na firewallu w routerach, tylko nie za bardzo wiem jak to zrobić, żeby przy okazji czegoś nie zepsuć. Pomożecie? smile

"Help me Obi-Wan Kenobi. You’re my only hope. " wink

2 (edytowany przez mar_w 2022-02-01 00:40:35)

Odp: reguły firewall

Moim zdaniem musisz:
1. Na routerze 10.10.2.1 (jak sądzę) robisz routing do sieci 10.10.3.0/24 via 10.10.1.3
Z firewallem nic nie robisz bo chcesz wychodzić z tej sieci, a połączenia wychodzące nie są blokowane.

2. Jednocześnie na routerze 10.10.3.1 (jak sądzę) zezwalasz na dostęp z WANu tylko z adresu 10.10.1.2 (bo takim adresem czyli swoim WANem będą wychodzić pakiety z sieci 10.10.2.0/24 ponieważ jest maskarada)
A musisz zezwolić na ten ruch ponieważ sieć 10.10.3.0/24 jest za WANem 10.10.1.3.
A każdy WAN na starcie blokuje połączenia przychodzące.
Na nim nie musisz ustawiać routingu bo gdy pakiet przyjdzie z adresu 10.10.1.2 to w odpowiedzi WAN (10.10.1.3) będzie umiał znaleźć drogę powrotną do niego.

To jest droga jednokierunkowa dla nowo nawiązywanych połączeń jak chciałeś - z sieci 10.10.2.0/24 do 10.10.3.0/24
Oczywiście sieć 10.10.3.0/24 będzie odpowiadać do sieci 10.10.2.0/24 za pośrednictwem adresu 10.10.1.2 ale to będą odpowiedzi na nawiązane połączenie a nie nowe inicjujące. Bez Twojej wiedzy nikt z sieci 10.10.3.0/24 nie włamie się do 10.10.2.0/24

Do sieci 10.10.4.0/24 robisz to samo co wyżej, czyli na 10.10.2.0/24 robisz routing do 10.10.4.0/24 via 10.10.1.4
A na 10.10.4.1 robisz odblokowanie WANu tylko dla adresu 10.10.1.2

Xiaomi AX3000T @ Netgear R6220
* DVBT2 - T230C *

3

Odp: reguły firewall

Dobra to ja też pytanie o regułę w FW.
Chciałbym otworzyć port 22 (zdalny dostęp do routera) ale tylko dla paru publicznych IP.
Jak zbudować reguły ?

Wszystkie posty dotyczą: TOTOLINK A7000R

4

Odp: reguły firewall

iptables -I INPUT -p tcp -s jakiś-adres-Ip1 -j ACCEPT
iptables -I INPUT -p tcp -s jakiś-adres-Ip2 -j ACCEPT
iptables -I INPUT -p tcp -s jakiś-adres-Ip3 -j ACCEPT

Przecież to podstawy iptables.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

5

Odp: reguły firewall

Cezary napisał/a:

iptables -I INPUT -p tcp -s jakiś-adres-Ip1 -j ACCEPT
iptables -I INPUT -p tcp -s jakiś-adres-Ip2 -j ACCEPT
iptables -I INPUT -p tcp -s jakiś-adres-Ip3 -j ACCEPT

Przecież to podstawy iptables.

jak chce regułe tylko na port 22 to dodać --dport 22

Wszystkie posty dotyczą: TOTOLINK A7000R

6

Odp: reguły firewall

iptables -I INPUT -p tcp -s jakiś-adres-Ip1 --dport 22 -j ACCEPT
iptables -I INPUT -p tcp -s jakiś-adres-Ip2 --dport 22 -j ACCEPT
iptables -I INPUT -p tcp -s jakiś-adres-Ip3 --dport 22 -j ACCEPT

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

7

Odp: reguły firewall

Cezary napisał/a:

iptables -I INPUT -p tcp -s jakiś-adres-Ip1 --dport 22 -j ACCEPT
iptables -I INPUT -p tcp -s jakiś-adres-Ip2 --dport 22 -j ACCEPT
iptables -I INPUT -p tcp -s jakiś-adres-Ip3 --dport 22 -j ACCEPT

i za tym czy przed tym

iptables -A INPUT -p tcp --dport 22 -j DROP

Bo w /etc/config/firewall mam otwarcie

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

config rule
    option name 'ssh'
    option src 'wan'
    option target 'ACCEPT'
    option proto 'tcp'
    option dest_port '22'

czyli najpierw sie importuje *.user a potem jest reguła z ssh

Wszystkie posty dotyczą: TOTOLINK A7000R

8

Odp: reguły firewall

Nie ma znaczenia, firewall.user jest wykonywany na końcu. Ale jeżeli masz już otwarte 22 na świat to po co chcesz to jeszcze dodatkowo otwierać dla określonych adresów IP?

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

9

Odp: reguły firewall

Chce port 22 otworzyć TYLKO dla wybranych IP a nie na cały świat.

Wszystkie posty dotyczą: TOTOLINK A7000R

10

Odp: reguły firewall

Więc czemu otworzyłeś na cały świat? Dodaj sobie do tej reguły option src_ip    xx.xx.xxx.xx i powtórz regułę dla wszystkich ip które chcesz otworzyć. I już bez żadnych zmian w firewall.user (albo zostaw firewall.user a wywal tą regułę którą zrobiłeś w /etc/config/firewall)

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

11

Odp: reguły firewall

Pytanie rooter głowny na IP 172.27.27.1  (MAP)
Głupi AP na adresie 172.27.27.5. (GAP)

Jak podłączę się po AP to moge się do niego zalogować.
Ale jak podłączę się pod główny rooter do nie mogę się do niego zalogować, nie dopowiada na pinga.

Co zmienić i na którym żeby miał do niego dostęp (na portach 22,80) z do GAP będąc podłączony do MAP

Wszystkie posty dotyczą: TOTOLINK A7000R

12

Odp: reguły firewall

W sumie nic. Są w jednej sieci, powinieneś mieć dostęp do jednego i drugiego. Pokaż

uci show network
uci show firewall

z jednego i drugiego

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

13

Odp: reguły firewall

MAP - Główny rooter
uci show network
network.loopback=interface
network.loopback.device='lo'
network.loopback.proto='static'
network.loopback.ipaddr='127.0.0.1'
network.loopback.netmask='255.0.0.0'
network.globals=globals
network.globals.packet_steering='1'
network.@device[0]=device
network.@device[0].name='br-lan'
network.@device[0].type='bridge'
network.@device[0].ports='lan1' 'lan2' 'lan3' 'lan4'
network.lan=interface
network.lan.device='br-lan'
network.lan.proto='static'
network.lan.ipaddr='172.27.27.1'
network.lan.netmask='255.255.255.0'
network.lan.ip6assign='60'
network.wan=interface
network.wan.device='wan'
network.wan.proto='dhcp'
network.wan.dns='8.8.8.8 80.50.50.100'
network.wan.type='bridge'
network.wan6=interface
network.wan6.device='wan'
network.wan6.proto='dhcpv6'
network.guest=interface
network.guest.device='br-guest'
network.guest.proto='static'
network.guest.ipaddr='10.1.1.1'
network.guest.netmask='255.255.255.128'
network.@device[1]=device
network.@device[1].name='br-guest'
network.@device[1].type='bridge'
network.@device[1].bridge_empty='1'
network.vpn=interface
network.vpn.device='tun0'
network.vpn.proto='none'


GAP -  uci show network

network.loopback=interface
network.loopback.device='lo'
network.loopback.proto='static'
network.loopback.ipaddr='127.0.0.1'
network.loopback.netmask='255.0.0.0'
network.globals=globals
network.@device[0]=device
network.@device[0].name='br-lan'
network.@device[0].type='bridge'
network.@device[0].ports='eth0.1'
network.lan=interface
network.lan.device='br-lan'
network.lan.proto='static'
network.lan.netmask='255.255.255.0'
network.lan.ip6assign='60'
network.lan.ipaddr='172.27.27.5'
network.lan.gateway='172.27.27.1'
network.lan.dns='8.8.8.8' '172.27.27.1'
network.wan=interface
network.wan.device='eth0.2'
network.wan.proto='dhcp'
network.wan.type='bridge'
network.@switch[0]=switch
network.@switch[0].name='switch0'
network.@switch[0].reset='1'
network.@switch[0].enable_vlan='1'
network.@switch_vlan[0]=switch_vlan
network.@switch_vlan[0].device='switch0'
network.@switch_vlan[0].vlan='1'
network.@switch_vlan[0].ports='0 1 6t'
network.@switch_vlan[1]=switch_vlan
network.@switch_vlan[1].device='switch0'
network.@switch_vlan[1].vlan='2'
network.@switch_vlan[1].ports='4 6t'
network.wwan=interface
network.wwan.proto='dhcp'
network.stabridge=interface
network.stabridge.proto='relay'
network.stabridge.network='lan wwan'

Wszystkie posty dotyczą: TOTOLINK A7000R

14

Odp: reguły firewall

A FireWall
MAP - uci show firewall
firewall.@defaults[0]=defaults
firewall.@defaults[0].syn_flood='1'
firewall.@defaults[0].input='ACCEPT'
firewall.@defaults[0].output='ACCEPT'
firewall.@defaults[0].forward='REJECT'
firewall.@zone[0]=zone
firewall.@zone[0].name='lan'
firewall.@zone[0].network='lan'
firewall.@zone[0].input='ACCEPT'
firewall.@zone[0].output='ACCEPT'
firewall.@zone[0].forward='ACCEPT'
firewall.@zone[1]=zone
firewall.@zone[1].name='wan'
firewall.@zone[1].network='wan' 'wan6'
firewall.@zone[1].input='REJECT'
firewall.@zone[1].output='ACCEPT'
firewall.@zone[1].forward='REJECT'
firewall.@zone[1].masq='1'
firewall.@zone[1].mtu_fix='1'
firewall.@forwarding[0]=forwarding
firewall.@forwarding[0].src='lan'
firewall.@forwarding[0].dest='wan'
firewall.@rule[0]=rule
firewall.@rule[0].name='Allow-DHCP-Renew'
firewall.@rule[0].src='wan'
firewall.@rule[0].proto='udp'
firewall.@rule[0].dest_port='68'
firewall.@rule[0].target='ACCEPT'
firewall.@rule[0].family='ipv4'
firewall.@rule[1]=rule
firewall.@rule[1].name='Allow-Ping'
firewall.@rule[1].src='wan'
firewall.@rule[1].proto='icmp'
firewall.@rule[1].icmp_type='echo-request'
firewall.@rule[1].family='ipv4'
firewall.@rule[1].target='ACCEPT'
firewall.@rule[2]=rule
firewall.@rule[2].name='Allow-IGMP'
firewall.@rule[2].src='wan'
firewall.@rule[2].proto='igmp'
firewall.@rule[2].family='ipv4'
firewall.@rule[2].target='ACCEPT'
firewall.@rule[3]=rule
firewall.@rule[3].name='Allow-DHCPv6'
firewall.@rule[3].src='wan'
firewall.@rule[3].proto='udp'
firewall.@rule[3].src_ip='fc00::/6'
firewall.@rule[3].dest_ip='fc00::/6'
firewall.@rule[3].dest_port='546'
firewall.@rule[3].family='ipv6'
firewall.@rule[3].target='ACCEPT'
firewall.@rule[4]=rule
firewall.@rule[4].name='Allow-MLD'
firewall.@rule[4].src='wan'
firewall.@rule[4].proto='icmp'
firewall.@rule[4].src_ip='fe80::/10'
firewall.@rule[4].icmp_type='130/0' '131/0' '132/0' '143/0'
firewall.@rule[4].family='ipv6'
firewall.@rule[4].target='ACCEPT'
firewall.@rule[5]=rule
firewall.@rule[5].name='Allow-ICMPv6-Input'
firewall.@rule[5].src='wan'
firewall.@rule[5].proto='icmp'
firewall.@rule[5].icmp_type='echo-request' 'echo-reply' 'destination-unreachable' 'packet-too-big' 'time-exceeded' 'bad-header' 'unknown-header-type' 'router-solicitation' 'neighbour-solicitation' 'router-advertisement' 'neighbour-advertisement'
firewall.@rule[5].limit='1000/sec'
firewall.@rule[5].family='ipv6'
firewall.@rule[5].target='ACCEPT'
firewall.@rule[6]=rule
firewall.@rule[6].name='Allow-ICMPv6-Forward'
firewall.@rule[6].src='wan'
firewall.@rule[6].dest='*'
firewall.@rule[6].proto='icmp'
firewall.@rule[6].icmp_type='echo-request' 'echo-reply' 'destination-unreachable' 'packet-too-big' 'time-exceeded' 'bad-header' 'unknown-header-type'
firewall.@rule[6].limit='1000/sec'
firewall.@rule[6].family='ipv6'
firewall.@rule[6].target='ACCEPT'
firewall.@rule[7]=rule
firewall.@rule[7].name='Allow-IPSec-ESP'
firewall.@rule[7].src='wan'
firewall.@rule[7].dest='lan'
firewall.@rule[7].proto='esp'
firewall.@rule[7].target='ACCEPT'
firewall.@rule[8]=rule
firewall.@rule[8].name='Allow-ISAKMP'
firewall.@rule[8].src='wan'
firewall.@rule[8].dest='lan'
firewall.@rule[8].dest_port='500'
firewall.@rule[8].proto='udp'
firewall.@rule[8].target='ACCEPT'
firewall.@rule[9]=rule
firewall.@rule[9].name='Support-UDP-Traceroute'
firewall.@rule[9].src='wan'
firewall.@rule[9].dest_port='33434:33689'
firewall.@rule[9].proto='udp'
firewall.@rule[9].family='ipv4'
firewall.@rule[9].target='REJECT'
firewall.@rule[9].enabled='0'
firewall.@include[0]=include
firewall.@include[0].path='/etc/firewall.user'
firewall.@rule[10]=rule
firewall.@rule[10].name='vpn'
firewall.@rule[10].src='wan'
firewall.@rule[10].target='ACCEPT'
firewall.@rule[10].proto='udp'
firewall.@rule[10].dest_port='1199'
firewall.@rule[11]=rule
firewall.@rule[11].name='openwrt_sshlan'
firewall.@rule[11].src='lan'
firewall.@rule[11].target='ACCEPT'
firewall.@rule[11].proto='tcp'
firewall.@rule[11].dest_port='22'
firewall.@zone[2]=zone
firewall.@zone[2].name='guest'
firewall.@zone[2].network='guest'
firewall.@zone[2].input='ACCEPT'
firewall.@zone[2].output='ACCEPT'
firewall.@zone[2].forward='ACCEPT'
firewall.@forwarding[1]=forwarding
firewall.@forwarding[1].src='guest'
firewall.@forwarding[1].dest='wan'
firewall.@rule[12]=rule
firewall.@rule[12].src='guest'
firewall.@rule[12].proto='udp'
firewall.@rule[12].src_port='67-68'
firewall.@rule[12].dest_port='67-68'
firewall.@rule[12].target='ACCEPT'
firewall.@rule[12].family='ipv4'
firewall.@rule[13]=rule
firewall.@rule[13].src='guest'
firewall.@rule[13].dest_port='53'
firewall.@rule[13].target='ACCEPT'
firewall.@rule[13].family='ipv4'
firewall.@rule[13].proto='tcpudp'
firewall.@rule[14]=rule
firewall.@rule[14].src='guest'
firewall.@rule[14].dest_port='5000'
firewall.@rule[14].target='ACCEPT'
firewall.@rule[14].family='ipv4'
firewall.@rule[14].proto='tcp'
firewall.@rule[15]=rule
firewall.@rule[15].src='wan'
firewall.@rule[15].dest='lan'
firewall.@rule[15].proto='gre'
firewall.@rule[15].target='ACCEPT'
firewall.@rule[16]=rule
firewall.@rule[16].src='wan'
firewall.@rule[16].dest='lan'
firewall.@rule[16].proto='tcpudp'
firewall.@rule[16].dest_port='1723'
firewall.@rule[16].target='ACCEPT'
firewall.@zone[3]=zone
firewall.@zone[3].name='vpn'
firewall.@zone[3].input='ACCEPT'
firewall.@zone[3].forward='ACCEPT'
firewall.@zone[3].output='ACCEPT'
firewall.@zone[3].network='vpn'
firewall.@forwarding[2]=forwarding
firewall.@forwarding[2].src='vpn'
firewall.@forwarding[2].dest='wan'
firewall.@rule[17]=rule
firewall.@rule[17].name='OpenVPN'
firewall.@rule[17].target='ACCEPT'
firewall.@rule[17].src='wan'
firewall.@rule[17].proto='udp'
firewall.@rule[17].dest_port='1199'

GAP - uci show firewall
firewall.@defaults[0]=defaults
firewall.@defaults[0].syn_flood='1'
firewall.@defaults[0].input='ACCEPT'
firewall.@defaults[0].output='ACCEPT'
firewall.@defaults[0].forward='REJECT'
firewall.@zone[0]=zone
firewall.@zone[0].name='lan'
firewall.@zone[0].input='ACCEPT'
firewall.@zone[0].output='ACCEPT'
firewall.@zone[0].forward='ACCEPT'
firewall.@zone[0].network='lan' 'wwan'
firewall.@zone[1]=zone
firewall.@zone[1].name='wan'
firewall.@zone[1].input='REJECT'
firewall.@zone[1].output='ACCEPT'
firewall.@zone[1].forward='REJECT'
firewall.@zone[1].masq='1'
firewall.@zone[1].mtu_fix='1'
firewall.@zone[1].network='wan' 'wwan'
firewall.@forwarding[0]=forwarding
firewall.@forwarding[0].src='lan'
firewall.@forwarding[0].dest='wan'
firewall.@rule[0]=rule
firewall.@rule[0].name='Allow-DHCP-Renew'
firewall.@rule[0].src='wan'
firewall.@rule[0].proto='udp'
firewall.@rule[0].dest_port='68'
firewall.@rule[0].target='ACCEPT'
firewall.@rule[0].family='ipv4'
firewall.@rule[1]=rule
firewall.@rule[1].name='Allow-Ping'
firewall.@rule[1].src='wan'
firewall.@rule[1].proto='icmp'
firewall.@rule[1].icmp_type='echo-request'
firewall.@rule[1].family='ipv4'
firewall.@rule[1].target='ACCEPT'
firewall.@rule[2]=rule
firewall.@rule[2].name='Allow-IGMP'
firewall.@rule[2].src='wan'
firewall.@rule[2].proto='igmp'
firewall.@rule[2].family='ipv4'
firewall.@rule[2].target='ACCEPT'
firewall.@rule[3]=rule
firewall.@rule[3].name='Allow-DHCPv6'
firewall.@rule[3].src='wan'
firewall.@rule[3].proto='udp'
firewall.@rule[3].src_ip='fc00::/6'
firewall.@rule[3].dest_ip='fc00::/6'
firewall.@rule[3].dest_port='546'
firewall.@rule[3].family='ipv6'
firewall.@rule[3].target='ACCEPT'
firewall.@rule[4]=rule
firewall.@rule[4].name='Allow-MLD'
firewall.@rule[4].src='wan'
firewall.@rule[4].proto='icmp'
firewall.@rule[4].src_ip='fe80::/10'
firewall.@rule[4].icmp_type='130/0' '131/0' '132/0' '143/0'
firewall.@rule[4].family='ipv6'
firewall.@rule[4].target='ACCEPT'
firewall.@rule[5]=rule
firewall.@rule[5].name='Allow-ICMPv6-Input'
firewall.@rule[5].src='wan'
firewall.@rule[5].proto='icmp'
firewall.@rule[5].icmp_type='echo-request' 'echo-reply' 'destination-unreachable' 'packet-too-big' 'time-exceeded' 'bad-header' 'unknown-header-type' 'router-solicitation' 'neighbour-solicitation' 'router-advertisement' 'neighbour-advertisement'
firewall.@rule[5].limit='1000/sec'
firewall.@rule[5].family='ipv6'
firewall.@rule[5].target='ACCEPT'
firewall.@rule[6]=rule
firewall.@rule[6].name='Allow-ICMPv6-Forward'
firewall.@rule[6].src='wan'
firewall.@rule[6].dest='*'
firewall.@rule[6].proto='icmp'
firewall.@rule[6].icmp_type='echo-request' 'echo-reply' 'destination-unreachable' 'packet-too-big' 'time-exceeded' 'bad-header' 'unknown-header-type'
firewall.@rule[6].limit='1000/sec'
firewall.@rule[6].family='ipv6'
firewall.@rule[6].target='ACCEPT'
firewall.@rule[7]=rule
firewall.@rule[7].name='Allow-IPSec-ESP'
firewall.@rule[7].src='wan'
firewall.@rule[7].dest='lan'
firewall.@rule[7].proto='esp'
firewall.@rule[7].target='ACCEPT'
firewall.@rule[8]=rule
firewall.@rule[8].name='Allow-ISAKMP'
firewall.@rule[8].src='wan'
firewall.@rule[8].dest='lan'
firewall.@rule[8].dest_port='500'
firewall.@rule[8].proto='udp'
firewall.@rule[8].target='ACCEPT'
firewall.@rule[9]=rule
firewall.@rule[9].name='Support-UDP-Traceroute'
firewall.@rule[9].src='wan'
firewall.@rule[9].dest_port='33434:33689'
firewall.@rule[9].proto='udp'
firewall.@rule[9].family='ipv4'
firewall.@rule[9].target='REJECT'
firewall.@rule[9].enabled='0'
firewall.@include[0]=include
firewall.@include[0].path='/etc/firewall.user'
firewall.@rule[10]=rule
firewall.@rule[10].name='ssh'
firewall.@rule[10].src='wan'
firewall.@rule[10].target='ACCEPT'
firewall.@rule[10].proto='tcp'
firewall.@rule[10].dest_port='22'
firewall.@rule[11]=rule
firewall.@rule[11].name='SSH'
firewall.@rule[11].src='lan'
firewall.@rule[11].src_port='22'
firewall.@rule[11].target='ACCEPT'
firewall.@rule[11].proto='tcp'

Wszystkie posty dotyczą: TOTOLINK A7000R

15

Odp: reguły firewall

network.wan.type='bridge' jest zbędne.

Masz most bezprzewodowy. Zawsze i wszędzie jest napisane że adres na lanie w takim przypadku masz mieć z innej klasy adresowej a do routera dostajesz się po adresie IP który otrzymasz na interfejsie radiowym. Źle skonfigurowałeś most bezprzewodowy.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.