Something is unclear to me about inbound traffic and firewalls.
My first assumption is that a firewall - say for a home router - should block all inbound ports. If you don't block all inbound ports, then surely hackers on the Internet can send packets to the devices on your network?
But if all inbound ports are blocked, how does any traffic get in?
For example, my understanding is that a browser sets up a connection to a web server - talking to port 80 on the web server, and some randomly assigned port number on the browser/client end - say for example port 30222. Browser asks for a page, web server sends it back addressed to the clients ip address/port 30222.
If the web server can send data to port 30222, then why couldn't any random hacker send data to port 30222?
How does the firewall view this? Should it be configured to permit all inbound connections?
I understand that there are stateful firewalls that examine the connection request from the client and can therefore selectively allow traffic on precisely that combination of client/port -> server/port - that make sense. In that context I can see you could block all inbound firewall ports on the home router because the home router is able to ensure traffic that it lets in is only between devices for a connection initiated internally - it is not possible in such context for a random hacker to send packets to a device on the internal network.
BUT - I don't think all firewalls are stateful are they? What about non-stateful firewalls - do they require allowing all inbound traffic?
So it is not clear to me if a home firewall should block all inbound ports or not. And if it does block all inbound ports, how does any data get in if it is not a stateful packet inspection firewall?