Configuring Firewall

Connection sharing, Firewall, Samba..etc
Forum rules
Before you post please read how to get help
Post Reply
xka
Level 1
Level 1
Posts: 24
Joined: Fri Jan 03, 2020 5:49 pm

Configuring Firewall

Post by xka »

How can I set up the firewall like this:
-Allow incoming and outgoing connections to IP 1.1.1.1 (all ports)
-Deny all other outgoing and incoming connections.


I've tried doing it in the Rules section, but:
-It doesn't allow me to add port range (I've tried to enter 1:65535, but the Add button is grey)
-I'm not sure if the allow or deny rule should go first

User avatar
WharfRat
Level 21
Level 21
Posts: 13770
Joined: Thu Apr 07, 2011 8:15 pm

Re: Configuring Firewall

Post by WharfRat »

I don't know why you would want to do this, but two simple iptables rules would do it.

Code: Select all

sudo iptables -P INPUT DROP
sudo iptables -P OUTPUT DROP

sudo iptables -A INPUT  -s 1.1.1.1 -m comment --comment "All ports accepted for this IP" -j ACCEPT
sudo iptables -A OUTPUT  -s 1.1.1.1 -m comment --comment "All ports accepted for this IP" -j ACCEPT
The policy is the last thing that will happen if the source is not 1.1.1.1 :wink:
ImageImage

Post Reply

Return to “Other networking topics”