iptables - dozvoli samo određene sajtove

Linux, poslužitelj, mreže i sigurnost

Moderator/ica: Moderatori/ce

Odgovori
Avatar
stefan
Moderator
Postovi: 4366
Pridružen/a: 28 sij 2009, 18:46
Spol: M
OS: openSUSE Leap KDE

iptables - dozvoli samo određene sajtove

Post Postao/la stefan »

Ok, pokušavam preko iptablesa napraviti da korisnik računala može pristupati samo određenim stranicama.
Prvi put ovo radim i malo zapoinjem...

Evo što sam naučio do sada:

Kod: Označi sve

# Resetiraj iptables rules
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

Kod: Označi sve

# Zabrani sav promet
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
E sad kad sam sve izblokirao, htio bih pomalo otvarati pristup nekim IP-ovima

Kod: Označi sve

iptables -A INPUT -s 83.169.60.59 -j ACCEPT
iptables -A OUTPUT -d 83.169.60.59 -j ACCEPT
I tu očito griješim. Na netu ima hrpa primjera, svi su različiti i ni jedan mi nije proradio.
Vjerujem da neki to imaju u malom prstu... pa ako može mala pomoć?
Like some other animals, the gecko can perform a neat trick when threatened by a predator: it can amputate its own tail. The dropped tail serves to distract the predator, and by losing it, the lizard can run faster.
Avatar
stefan
Moderator
Postovi: 4366
Pridružen/a: 28 sij 2009, 18:46
Spol: M
OS: openSUSE Leap KDE

Re: iptables - dozvoli samo određene sajtove

Post Postao/la stefan »

Našao sam!
http://www.linuxforums.org/forum/securi ... linux.html

Kod: Označi sve

iptables -F
iptables -X
iptables -P INPUT DROP
iptables -P OUTPUT DROP

iptables -A INPUT -s ip.of.that.site -j ACCEPT
iptables -A INPUT -s ip.of.your.DNS -j ACCEPT
iptables -A INPUT -s ! ip.of.that.site -j DROP


iptables -A OUTPUT -d ip.of.that.site -j ACCEPT
iptables -A OUTPUT -d ip.of.your.DNS -j ACCEPT
iptables -A OUTPUT -d ! ip.of.that.site -j DROP
Like some other animals, the gecko can perform a neat trick when threatened by a predator: it can amputate its own tail. The dropped tail serves to distract the predator, and by losing it, the lizard can run faster.
Avatar
glaskoncILLa
Postovi: 5678
Pridružen/a: 28 vel 2009, 16:36

Re: iptables - dozvoli samo određene sajtove

Post Postao/la glaskoncILLa »

daj iptables -L
...."Have you mooed today?"...
..It’s that time of the decade: I’m reinstalling Debian..
Avatar
stefan
Moderator
Postovi: 4366
Pridružen/a: 28 sij 2009, 18:46
Spol: M
OS: openSUSE Leap KDE

Re: iptables - dozvoli samo određene sajtove

Post Postao/la stefan »

glaskoncILLa je napisao/la:daj iptables -L
Sad sam ih resetirao :)
Ma uglavnom sve je DROP i onda ACCEPT za DNS i za sajt.

AJd probati ću ponovno. Da računalo ima pristup samo na LZS:

Kod: Označi sve

# Zabrani sav promet
iptables -F
iptables -X
iptables -P INPUT DROP
iptables -P OUTPUT DROP

# dns in
iptables -A INPUT -s 192.168.1.1 -j ACCEPT
# lzs in
iptables -A INPUT -s 83.169.60.59 -j ACCEPT
#iptables -A INPUT ! -s 83.169.60.59 -j DROP

# dns out
iptables -A OUTPUT -d 192.168.1.1 -j ACCEPT
# lzs out
iptables -A OUTPUT -d 83.169.60.59 -j ACCEPT
#iptables -A OUTPUT ! -d 83.169.60.59 -j DROP

Kod: Označi sve

linux-scyp:/home/stefan # iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  dsldevice.lan        anywhere            
ACCEPT     all  --  silicij.avalon.hr    anywhere            

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             dsldevice.lan       
ACCEPT     all  --  anywhere             silicij.avalon.hr   
Like some other animals, the gecko can perform a neat trick when threatened by a predator: it can amputate its own tail. The dropped tail serves to distract the predator, and by losing it, the lizard can run faster.
Avatar
glaskoncILLa
Postovi: 5678
Pridružen/a: 28 vel 2009, 16:36

Re: iptables - dozvoli samo određene sajtove

Post Postao/la glaskoncILLa »

iako, ako te zelis napraviti na smislen nacin, puno je bolje biti cim precizniji i raditi sa konkretnim portovima (li jos bolje deep packet inspection, citaj snort) jer je uvijek moguce da se netko proxa kroz ssh ili vec nesto ako mu dopustis kompletan IP promet..
...."Have you mooed today?"...
..It’s that time of the decade: I’m reinstalling Debian..
Odgovori