If not I could buy a router which has such a function and place in before the gateway router, no?
In this case you have two choices:
- If the new router has a builtin modem, replace your present gateway router with the new one.
- If the new router doesn't have a builtin modem, place it before your present gateway. To prevent double NAT, bridge your present gateway, that is reduce its function to be a modem only and not a router.
Getting back to the firewall is there a hardware solution in which I could choose which ports on the switch have access to internet or LAN services or both?
Yes, for example look at the following picture, where your gateway router is either replaced by a firewall (if the firewall has a builtin modem) or where the firewall is placed behind your gateway router, which is reduced to work as a modem only:
.----------------------------.
| |
| FIREWALL |
| |
.-+-. |
| | |
|-- VLAN1----------- LAN1 <-----. |
| | | |
`-+-´ | |
.-----. | | |
| | | | |
| SRV | | | |
| | | | |
`--+--´ .-+-. | |
| | <-----´ |
|-- VLAN2---+------- LAN2 | |
| -----------------------. |
`-+-´ | .-+-. .--. .--.
| `---> | ´ `-´ `
| | WAN ------( INTERNET )
| .---> | . .-. .
.-+-. | `-+-´ `--´ `--´
| | | |
|-- VLAN3----------- LAN3 -----------------------´ |
| | |
`-+-´ |
| |
`----------------------------´
Here it is assumed that the firewall has at least three layer 3 ports LAN1, LAN2, LAN3 (that is they belong to three different IP subnets) which have to be connected to 3 switch ports, where these switch ports have different VLANs VLAN1, VLAN2 and VLAN3. Your server SRV is connected to VLAN2 (that is to another switch port that is assigned VLAN2). Inside your firewall your would allow traffic between LAN ports LAN1 and LAN2 in both directions. But you will only allow traffic from ports LAN2 and LAN3 to pass to the WAN port that is to the Internet. All other communication (WAN --> LANx, LAN1 --> WAN, LAN3 <--> LAN1, LAN3 <--> LAN2) is blocked.
The same holds true for the following slightly different scenario:
.----------------------------.
| |
| FIREWALL |
| |
| .---. |
| | | |
|-- VLAN1-----------. | .---- LI1 <----. |
| | | | | | |
| | | `---´ | |
.-----. | | | | |
| | | | | | |
| SRV | | | | | |
| | | | | | |
`--+--´ | .-+-. | .---. | |
| `---------´ | <----´ |
|-- VLAN2---+-------- LAN --------- LI2 | |
.---------. | ---------. |
| `-+-´ | `---´ | .-+-. .--. .--.
| | | `---> | ´ `-´ `
| | | | WAN ------( INTERNET )
| | | .---> | . .-. .
| | | .---. | `-+-´ `--´ `--´
| | | | | | |
|-- VLAN3-----------´ | `---- LI3 ---------´ |
| | | |
| `---´ |
| |
`----------------------------´
Here the firewall only has a single layer 2 interface LAN. But it supports the feature to form a number of logical layer 3 interfaces, e.g. LI1, LI2 and LI3, where each of them is assigned a different VLAN, namely VLAN1, VLAN2 and VLAN3 respectively. In this case the LAN port connects to a single switch port, where this switch port has to be assigned the same three VLANs VLAN1, VLAN2 and VLAN3. Looking at allowed and blocked traffic flows, the same statements as in the above scenario are valid, you just have to replace LAN1 by LI1, LAN2 by LI2 and LAN3 by LI3.