Toon posts:

[IPtales] IP restictie op 1 TCP poort (voor SSH)

Pagina: 1
Acties:

Verwijderd

Topicstarter
Beste tweakers, ik ben weer eens bezig met het bijwerken van mijn firewall. Nu kwam ik op het geniale ID om mijn sshd maar helemaal van de buitenwereld af te schermen en slechts op mijn LAN beschikbaar te houden met (waar default policy DROP all is):

code:
1
2
3
4
5
6
7
8
9
#SSH server intern (sshd)
/sbin/iptables --table filter -A INPUT -i eth0 -p tcp --source-port 1024:65535 --destination-port 22 --tcp-flags SYN,ACK,RST,FIN SYN -m state --state NEW -j ACCEPT
/sbin/iptables --table filter -A OUTPUT -o eth0 -p tcp --source-port 22 --destination-port 1024:65535 --tcp-flags SYN,ACK,RST,FIN SYN,ACK -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables --table filter -A INPUT -i eth0 -p tcp --source-port 1024:65535 --destination-port 22 --tcp-flags SYN,ACK,RST,FIN ACK -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables --table filter -A OUTPUT -o eth0 -p tcp --source-port 22 --destination-port 1024:65535 --tcp-flags SYN,ACK,RST,FIN ACK -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables --table filter -A OUTPUT -o eth0 -p tcp --source-port 22 --destination-port 1024:65535 --tcp-flags SYN,ACK,RST,FIN ACK,FIN -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables --table filter -A INPUT -i eth0 -p tcp --source-port 1024:65535 --destination-port 22 --tcp-flags SYN,ACK,RST,FIN ACK,FIN -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables --table filter -A OUTPUT -o eth0 -p tcp --tcp-flags SYN,RST,FIN RST -m state  --state ESTABLISHED,RELATED  -j ACCEPT
/sbin/iptables --table filter -A INPUT -i eth0 -p tcp --tcp-flags SYN,RST,FIN RST -m state  --state ESTABLISHED,RELATED  -j ACCEPT


Maar nu is er toch een persoon die me regelmatig werkzaamheden op mijn servertje moet uitvoeren, hij heeft een vast IP. Dus nu zou ik iets moeten kunnen bedenken zodat IP tables TCP poort 22 (met bovenstaande regels) op ppp0 ALLEEN openzet voor een vast IPadres.

Ik kan wel threads op forums vinden die interessand leken zoals:
Re: iptables can filter by hostname and not ip address ?
... If you input a rule with a hostname, it translates ... of course $IPT is /usr/sbin/iptables,
$FWDPORTS are ... Next by Date: Re: ssh : command restriction possible ? ...
cert.uni-stuttgart.de/archive/usenet/comp.os.linux.security/ 2002/10/msg00218.html - 5k
Maar die geven allemaal 404 :'(. Op de netfilter site is al helemaal niet veel te vinden en mijn 4 firewall howto's vermelding nix over restrictie op IP. Het schijnt wel mogelijk te zijn op hostname maar ik kan nergens vinden hoe?

  • blackd
  • Registratie: Februari 2001
  • Niet online
Verwijderd schreef op 09 May 2003 @ 02:39:
Op de netfilter site is al helemaal niet veel te vinden
Oh?
Specifying Source and Destination IP Addresses

Source (`-s', `--source' or `--src') and destination (`-d', `--destination' or `--dst') IP addresses can be specified in four ways. The most common way is to use the full name, such as `localhost' or `www.linuxhq.com'. The second way is to specify the IP address such as `127.0.0.1'.

The third and fourth ways allow specification of a group of IP addresses, such as `199.95.207.0/24' or `199.95.207.0/255.255.255.0'. These both specify any IP address from 199.95.207.0 to 199.95.207.255 inclusive; the digits after the `/' tell which parts of the IP address are significant. `/32' or `/255.255.255.255' is the default (match all of the IP address). To specify any IP address at all `/0' can be used, like so:
code:
1
2
3
[ NOTE: `-s 0/0' is redundant here. ]
# iptables -A INPUT -s 0/0 -j DROP
#

This is rarely used, as the effect above is the same as not specifying the `-s' option at all.
Pieter:
en mijn 4 firewall howto's vermelding nix over restrictie op IP. Het schijnt wel mogelijk te zijn op hostname maar ik kan nergens vinden hoe?
Meer leesmaterie: http://www.linuxguruz.com/iptables/

9000Wp o/w SolarEdge SE6K - Panasonic 5kW bi-bloc - gasloos sinds 17-7-2023


Verwijderd

iptables -A INPUT -i et0 -p tcd -s x.x.x.x -sport zz -d y.y.y.y -dport qq -j ACCEPT

staat allemaal n die documentjes op de netfilter site. bv:
Herkomst en doel
Herkomst (`-s', `--source' of `--src') en doel (`-d', `--destination' or `--dst') IP adressen kunnen worden opgegeven op vier manieren. Natuurlijk kan je gewoon een IP-adres opgeven, maar je kan ook een hostname gebruiken, zoals `localhost' of `www.linuxhq.com'.

De derde en vierde manieren laten het toe om meerdere IP-adressen te specificeren. `199.95.207.0/255.255.255.0', bijvoorbeeld geeft 255 ip-adressen aan. Ook geldig is `199.95.207.0/24'. Allebei geven ze IP-adressen aan van 199.95.207.0 tot 199.95.207.255.

Twee speciale varianten hiervan zijn 1.2.3.4/32, waar de /32 aangeeft dat het IP-adres helemaal moet voldoen. Dit is standaard. 1.2.3.4/0 kan ook, in welk geval het IP-adres helemaal niet uitmaakt. In dit geval wordt meestal 0/0 opgegeven als IP adres. Dit is standaard als de -s of -d optie weggelaten wordt, dus als er geen herkomst of doel adres opgegeven wordt. Daarom wordt het ook weinig gebruikt:


[ NOTE: `-s 0/0' is redundant here. ]
# iptables -A INPUT -s 0/0 -j DROP
#
uit de nederlandstalige howto:
http://www.netfilter.org/...et-filtering-HOWTO-7.html

//edit
lol, zie nu pas dat ik hetzelfde stukje quote als mijn voorganger..nu ja, dat is dan ook het relevante stuk in deze kweste :)

[ Voor 8% gewijzigd door Verwijderd op 09-05-2003 06:11 ]