联系

AWS 安全组 vs MikroTik 防火墙:有什么区别

首页 / 博客

9 分钟阅读
ZILL E ALI11 月 17, 2026亚马逊网络服务(AWS)

AWS Security Groups vs MikroTik Firewall comes down to two different design philosophies, and that difference causes more confusion for network engineers moving between them than any single config detail. RouterOS firewall chains mix allow and deny rules together and evaluate them top to bottom; Security Groups allow only, are always stateful, and ignore rule order entirely. Neither model is wrong, but assuming one works like the other is where real outages come from.

This is a direct comparison: how each one actually works under the hood, where Network ACLs fit into the AWS side of the picture, and the specific mistakes that show up most often when someone who thinks in RouterOS filter chains first touches a Security Group.

How RouterOS firewall chains work: input, forward, output

RouterOS’s firewall filter has three built-in chains:

  • input – traffic destined for the router itself (management access, services running on the router)
  • forward – traffic passing through the router, from one interface to another (the bulk of real LAN/WAN traffic)
  • output – traffic originating from the router itself

Rules in each chain are evaluated top to bottom, and the first matching rule wins (processing stops there unless it is a non-terminating action like log). Rules are stateless unless you explicitly match on connection-state (established, related, new, invalid), which most production configs do, almost as a matter of convention: accept established/related early, then only evaluate new connections against the real policy. Both allow (accept) and deny (drop, reject) actions live in the same chain, mixed together in whatever order you wrote them, with an implicit “accept everything” at the very end unless you add an explicit drop-all rule yourself.

How Security Groups work: stateful, allow rules only, attached per ENI

A Security Group is attached to a network interface (ENI), not to a router or gateway device, since there usually is no single router in the RouterOS sense inside a VPC. Every instance, load balancer, or managed service with a network interface gets one or more Security Groups attached to it directly.

Three structural differences from a RouterOS filter chain matter immediately:

  1. Stateful by default, always. There is no equivalent of forgetting to add connection-state=established,related. If you allow inbound traffic on a port, the matching outbound reply is automatically permitted, full stop. There is no way to turn this off.
  2. Allow-only, no deny. A Security Group rule can only permit traffic; there is no drop or reject rule inside a Security Group. Anything not explicitly allowed is implicitly blocked. This is the opposite of RouterOS’s “default accept unless you add a drop,” and it is the single most common source of confusion for someone used to writing explicit deny rules.
  3. Rule order does not matter. RouterOS evaluates top-down and stops at the first match. Security Groups evaluate all applicable rules together; since there is no deny action to conflict with an allow, order has no effect on the outcome.

A Security Group rule can reference a CIDR block (like a RouterOS address-list) or, usefully, another Security Group as the source – “allow traffic from anything that has Security Group X attached,” which has no direct RouterOS equivalent and is genuinely useful for tiered application architectures (web tier Security Group allowed into database tier Security Group, regardless of IP).

NACLs as the stateless counterpart

Network ACLs are the one piece of AWS networking that behaves close to a traditional RouterOS filter chain: they are stateless, attached at the subnet level (not per interface), evaluated in numbered rule order with first-match-wins, and they support explicit deny rules.

In practice, most AWS architectures leave NACLs at their default “allow all in, allow all out” and put essentially all real policy into Security Groups. This is a deliberate inversion from how a RouterOS network is usually built, where the router’s filter chain carries nearly all the enforcement. If you are migrating a mental model from MikroTik, resist the instinct to reach for NACLs as your primary tool just because they feel more familiar; Security Groups are what you are expected to use for day-to-day policy, and NACLs are reserved for coarse, subnet-wide blocking (an IP range you want to deny outright, for instance, where only NACLs can actually express “deny”).

AWS Security Groups vs MikroTik Firewall: diagram comparing RouterOS input, forward and output chains with Security Groups and NACLs in a VPC
Where filtering happens: RouterOS chains vs AWS Security Groups and NACLs.

AWS Security Groups vs MikroTik Firewall: Side-by-Side Comparison

RouterOS Firewall Filter AWS Security Group AWS NACL
Attached to a router/interface Attached to a network interface (ENI) Attached to a subnet
Stateless unless matched explicitly Always stateful Always stateless
Allow and deny rules, mixed Allow only, implicit deny for the rest Allow and deny, explicit
Top-down, first match wins Order does not matter Top-down, first match wins (by rule number)
Can reference address-lists Can reference another Security Group as source CIDR-based only

Common mistakes moving from one model to the other

  • Trying to add a “deny” rule in a Security Group. It is not possible, by design. If you need to actively block a specific source while allowing everything else, that has to happen at the NACL level instead, or by not including that source in anything the Security Group allows.
  • Forgetting that a security group’s inbound and outbound rules are independent. Allowing inbound on port 443 does not automatically allow outbound on port 443 for a different, unrelated connection; it only covers the automatic stateful reply to that specific allowed inbound session. Outbound rules for anything your instance initiates still need their own entry (though many default Security Groups ship with “allow all outbound” already in place, which can quietly hide this distinction until you tighten it).
  • Assuming NACLs are the main policy layer. Engineers coming from a router-centric firewall background sometimes build out detailed NACL rules first, by habit, then find Security Groups are still wide open. Both need to be correct, but Security Groups do almost all of the real work in a typical setup.
  • Not accounting for statefulness when reasoning about rule sets. A RouterOS habit of writing both directions of a rule explicitly (because the firewall is stateless by default without a state match) carries over as unnecessary, duplicate outbound allow rules in a Security Group that do nothing extra, since the reply traffic was already going to be allowed automatically.
  • Attaching too many Security Groups to one interface and losing track of what is actually allowed. Rules from every attached Security Group are combined (as a union of allows), which is easy to lose track of compared to a single ordered filter chain. Keep the count per interface small and intentional.

Why This Works: Default-Deny in Both Models

Underneath the differences, RouterOS firewall chains and Security Groups are both built on the same core security principle: default-deny. A well-built RouterOS filter chain ends with an explicit drop-all rule so nothing unaccounted-for slips through; a Security Group achieves the identical outcome structurally, by simply never having a mechanism to allow anything you did not list. The difference is just where that default-deny guarantee lives. On RouterOS, it is a rule you have to remember to write and keep at the bottom of the chain, which means it can be accidentally broken by inserting a stray accept rule after it, or forgetting it on a freshly provisioned router. On a Security Group, the guarantee is structural; there is no rule ordering to get wrong and no way to accidentally create an unintended allow-all, because the only thing you can ever add is a narrow permission.

This is also why migrating a RouterOS-style mental model directly onto Security Groups sometimes produces more permissive rules than intended: an engineer used to compensating for “default accept unless I drop it” by writing broad, catch-all accept rules early in a chain brings that same habit into a Security Group, where every rule is already narrow by construction, and ends up allowing more than they would have on RouterOS. Writing Security Group rules as narrowly as you would write the last, most specific rule in a RouterOS chain, rather than the first, broad one, is the right instinct to carry over.

FAQ

Can a Security Group block traffic the way a RouterOS drop rule does?
Not directly. The closest equivalent is simply not allowing that traffic in the first place (since everything is implicit-deny by default), or using a NACL if you need an explicit, traffic-wide block regardless of what any Security Group says.

Is there a RouterOS equivalent of a Security Group referencing another Security Group as its source?
Not natively. The closest practical equivalent on RouterOS is building and maintaining address-lists per role (web servers, database servers) and writing filter rules against those lists, but you are maintaining the membership yourself; a Security Group-to-Security-Group reference updates automatically as instances are attached or removed.

Which one should I learn first if I am starting from a MikroTik background?
Security Groups. They are what you will use for almost every real rule in a VPC, and the biggest unlearning curve (allow-only, always stateful) is specific to them, not NACLs.

Conclusion

The short version of AWS Security Groups vs MikroTik Firewall: Security Groups are always stateful and allow-only, attached per network interface rather than per router, and rule order never matters because there is no deny action to conflict with. NACLs are the closer analogue to a traditional RouterOS filter chain, but they should stay a coarse, subnet-level backup, not your primary policy tool. Learn Security Groups first, keep NACLs simple, and the biggest unlearning curve from RouterOS is already behind you.

作者

ZILL E ALI

拥有 MTCNA 和 MTCRE 认证的网络工程师、ISP 基础设施专家,Developer Zon 创始人。在此撰写关于 MikroTik、Cisco、ISP 基础设施以及偶尔的构建日志。

留下回复

本站使用 Akismet 来减少垃圾评论。了解您的评论数据如何被处理。