* Simple NFT example
@ 2014-10-30 19:43 Loganaden Velvindron
2014-11-19 11:00 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Loganaden Velvindron @ 2014-10-30 19:43 UTC (permalink / raw)
To: netfilter
Hi guys,
I tried to cook up a simple example.
Pablo sent me feedback on my example.
First we setup a basic table for IPv4.
table ip means that "ip" implicitly means IPv4.
The input chain is the "incoming" traffic on a machine. For example,
assuming that you have a desktop running SSH, and you would like to
have a simple ruleset which is suitable for a desktop. You'd want to
allow ping (so that you can ping your laptop on the network).
Some deamons bind to localhost interface. It's a good idea to accept
connections on local interface, so this should be allowed.
The rest is rejected.
For example, if your desktop runs a web server on port 80, it won't be
accessible. You need to enable it by adding another rule.
fw.basic:
table ip filter {
chain input {
type filter hook input priority 0;
ct state established,related accept
# accept connections for localhost interface
iif lo accept
# Accept SSH connections on port 22
tcp dport 22 accept
# Allow ICMP packets such as "ping"
ip protocol icmp accept
# Reject any other connections
reject
}
}
You can run this simply by typing:
nft -f fw.basic
Any feedback welcomed.
--
This message is strictly personal and the opinions expressed do not
represent those of my employers, either past or present.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Simple NFT example
2014-10-30 19:43 Simple NFT example Loganaden Velvindron
@ 2014-11-19 11:00 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2014-11-19 11:00 UTC (permalink / raw)
To: Loganaden Velvindron; +Cc: netfilter
On Thu, Oct 30, 2014 at 11:43:29PM +0400, Loganaden Velvindron wrote:
> Hi guys,
>
> I tried to cook up a simple example.
>
> Pablo sent me feedback on my example.
>
> First we setup a basic table for IPv4.
>
> table ip means that "ip" implicitly means IPv4.
>
> The input chain is the "incoming" traffic on a machine. For example,
> assuming that you have a desktop running SSH, and you would like to
> have a simple ruleset which is suitable for a desktop. You'd want to
> allow ping (so that you can ping your laptop on the network).
>
> Some deamons bind to localhost interface. It's a good idea to accept
> connections on local interface, so this should be allowed.
>
> The rest is rejected.
>
> For example, if your desktop runs a web server on port 80, it won't be
> accessible. You need to enable it by adding another rule.
>
> fw.basic:
>
> table ip filter {
> chain input {
>
> type filter hook input priority 0;
>
> ct state established,related accept
>
> # accept connections for localhost interface
> iif lo accept
>
> # Accept SSH connections on port 22
> tcp dport 22 accept
>
> # Allow ICMP packets such as "ping"
> ip protocol icmp accept
>
> # Reject any other connections
> reject
> }
> }
>
>
> You can run this simply by typing:
>
> nft -f fw.basic
>
> Any feedback welcomed.
I have added this to the wiki:
http://wiki.nftables.org/wiki-nftables/index.php/Simple_ruleset_for_a_workstation
It would be good to have examples for IPv6 and IPv4/IPv6 using the
inet family.
Thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-19 11:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-30 19:43 Simple NFT example Loganaden Velvindron
2014-11-19 11:00 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox