yesyou mean 'Since' when you say 'From' in here, right?
yesyou mean 'Since' when you say 'From' in here, right?
Yes, but the IP address is always routed to lo0:
Code:192.168.101.1 link#2 UHS lo0 192.168.101.65 link#10 UHS lo0 192.168.101.129 link#11 UHS lo0 192.168.101.193 link#12 UHS lo0
I always imagine myself to be a network packet. The only thing a router (gateway_enable) cares about is the destination IP address. So packet gets sent to 192.168.101.1 and walks in on $ifW. Runs into a firewall rule,pass in on igb1 inet proto icmp all icmp-type echoreq. Good, allowed in. Then looks at routing table where to go next, sees 192.168.101.65 is right here. Hey, service with that IP. And the response is allowed back due to the state.
Explanation: The 1st rule allows incoming ICMP echo-request on $ifW. Keep state will be attached by default (Thanks to VladiBG) which causes that the returning traffic will pass as well, meaning that the block (2nd rule) is ignored as the packet has already reached the host. In addition because the IP address is attached to the host and not to the interface all other interface will respond as well.pass in on $ifW inet proto icmp icmp-type echoreq
block out on $ifW inet proto icmp from 192.168.101.65
Explanation: The 1st rule allows incoming ICMP echo-request on $ifW without keep state actived which causes that the returning traffic will not just simply pass. The 2nd rule is needed to that and to demonstration the fact the IP address is attached to the host and not to the interface the 2nd rule allows a different IP address then the one from the interface facing the actual senders network respond. But I got a question, right now gateway_enable="YES" is set. Does this have any impact here, it shouldn't if I understand correctly, right?pass in on $ifW inet proto icmp icmp-type echoreq no state
pass out on $ifW inet proto icmp from 192.168.101.65
Explanation: The 1st rule allows incoming ICMP echo-request on $ifW. Keep state will be attached by default which causes that returning traffic will pass, except for all incoming ICMP traffic with destination 192.168.101.65 which will be blocked.pass in on $ifW inet proto icmp icmp-type echoreq
block in on $ifW inet proto icmp to 192.168.101.65
Explanation: The 1st rule allows incoming ICMP echo-request on $ifW. Keep state will be attached by default which causes that returning traffic will pass, BUT the quick keyword causes that the 2nd rule (block statement) is ignored so all address will be reachable by ICMP echo-request on that host.pass in quick on $ifW inet proto icmp icmp-type echoreq
block in on $ifW inet proto icmp to 192.168.101.65
Yep. You are on the right track. Keep going.That's it, isn't it?
pass in on $ifW inet proto icmp icmp-type echoreq
block in on $ifW inet proto icmp to 192.168.101.65
pass in on $ifW inet proto icmp to !192.168.101.65 icmp-type echoreq
block all will apply and block the access to 192.168.101.65 specifically.| src / dst proto: ICMP | vlan W | vlan O | vlan S | vlan M | WAN |
| vlan W | PASS | BLOCK | BLOCK | BLOCK | PASS |
| vlan O | PASS | PASS | PASS | PASS | PASS |
| vlan S | BLOCK | BLOCK | PASS | BLOCK | BLOCK |
| vlan M | BLOCK | BLOCK | BLOCK | PASS | BLOCK |
| WAN | BLOCK | BLOCK | BLOCK | BLOCK | PASS |
#1st rule
block all
#ICMP src vlan W
pass in on $ifW inet proto icmp icmp-type echoreq
block in quick on $ifW inet proto icmp to { $ifO:network $ifS:network $ifM:network }
pass out on $ifWifi inet proto icmp from { $ifW:network $ifO:network} icmp-type echoreq
#ICMP src vlan O
pass in on $ifO inet proto icmp icmp-type echoreq
pass out on $ifO inet proto icmp from $ifO:network icmp-type echoreq
#ICMP src vlan S
pass in on $ifS inet proto icmp to $ifS:network icmp-type echoreq
pass out on $ifS inet proto icmp from { $ifS:network $ifO:network } icmp-type echoreq
#ICMP src vlan M
pass in on $ifM inet proto icmp to $ifM:network icmp-type echoreq
pass out on $ifM inet proto icmp from { $ifM:network $ifO:network } icmp-type echoreq
Yes.If your host has 2 NICs, it would be quite possible for it to have 2 IP addresses. Even a consumer-grade router would have 2 IP addresses: an Internet-legal one, and an internal one, like 192.168.1.1.
--
an IP address gets bound to an interface on the host. In case of a router, one IP address (192.168.1.1) can be bound to several interfaces (ethernet plugs) - this is a case of "One or more".
--
If SSH is only listening on 192.168.101.3, port 22, it would not accept connections on 192.168.101.4, port 22.
pass in on $ifW inet proto tcp to port ssh
Can you please be more specific which of my statements are wrong?It's wrong. Check again your rules.
Same for:pass out on $ifWifi inet proto icmp from { $ifW:network$ifO:network} icmp-type echoreq
pass out on $ifS inet proto icmp from { $ifS:network$ifO:network} icmp-type echoreq
pass out on $ifM inet proto icmp from { $ifM:network$ifO:network} icmp-type echoreq
pass in on $ifW inet proto icmp icmp-type echoreq
block in quick on $ifW inet proto icmp to { $ifO:network $ifS:network $ifM:network }
pass out on $ifW inet proto icmp from { ifW:network $ifO:network } icmp-type echoreq
pass out on $ifS inet proto icmp from { $ifS:network $ifO:network } icmp-type echoreq
pass out on $ifM inet proto icmp from { $ifM:network $ifO:network } icmp-type echoreq
You are right that after routing you need $if0:network to pass out from $ifW. It will look like thisblock in
pass out
block in quick $ifW inet proto icmp to $ifO:network
pass in on $ifW inet proto icmp icmp-type echoreq
pass in on $ifO inet proto icmp icmp-type echoreq
src: 192.168.101.80 ->dst 192.168.101.4
pass in on lagg0.64 192.168.101.80 > 192.168.101.4 ICMP8 (state: all icmp 192.168.101.4 <- 192.168.101.80)
pass out on igb1 192.168.101.80 > 192.168.101.4 ICMP8 (state: all icmp 192.168.101.80 -> 192.168.101.4)
pass in on igb1 192.168.101.4 > 192.168.101.80 ICMP0 (match state 192.168.101.80 -> 192.168.101.4)
pass out on lagg0.64 192.168.101.4 > 192.168.101.80 ICMP0 (match state 192.168.101.4 <- 192.168.101.80)
block in
block in quick $ifW inet proto icmp to $ifO:network
pass in on $ifW inet proto icmp icmp-type echoreq
pass in on $ifO inet proto icmp icmp-type echoreq
src: 192.168.101.80 ->dst 192.168.101.4
pass in on lagg0.64 192.168.101.80 > 192.168.101.4 ICMP8 (state all icmp 192.168.101.4 <- 192.168.101.80)
pass out all on igb1 no state 192.168.101.80 > 192.168.101.4 ICMP8 (NO STATE)
block in on igb1 192.168.101.4 > 192.168.101.80 ICMP0
Here's a perfect example. This is really helpful information, yet I have not seen it in ANY of the dozen tutorials I've read so far.Since FreeBSD 7.0 the "keep state" is default for every rule. If you want to disable it use "no state" option.
set state-defaults
The state-defaults option sets the state options for states created
from rules without an explicit keep state. For example:
set state-defaults no-sync
Because flags S/SA is applied by default (unless no state is speci-
fied), only the initial SYN packet of a TCP handshake will create a
state for a TCP connection.