iptable nur bestimmte Client

Pello

Newbie
Registriert
Mai 2018
Beiträge
4
Ich versuche seit längerem das nur bestimmte Clients ausschließlich eine VPN Verbindung nutzen sollen. Mein bisheriger Ansatz war IPFire als multiple OpenVPN Client zu nutzen. Vom Prinzip ist das so gedacht, dass Client0 immer Interface tun0, Client1 immer tun1 und so weiter nutzt. In IPFire hatte ich gedacht per Firewall Rule die Verbindung über red0(Verbindung nach draußen) zu verweigern, um zu verhindern das die ohne VPN ins Internet kommen. Zuvor habe ich noch nie was mit Netzwerken gemacht und bekomme es einfach nicht hin.

Aktueller Ansatz ist
Code:
iptables -t nat -A POSTROUTING -s 192.168.1.10 -o tun0 -j MASQUERADE

Damit nutzt der gewünschte Client das VPN, allerdings können die anderen Clients nun nicht mehr nach draußen. Ich verstehe nicht warum. Die genannte Firewall Regel ist übrigens noch nicht vorhanden. Weiß einer, wie das aussehen muss damit es funktioniert?
 
Pello schrieb:
Aktueller Ansatz ist
Code:
iptables -t nat -A POSTROUTING -s 192.168.1.10 -o tun0 -j MASQUERADE
Nat? MASQUERADE? Das macht ja nun gar keinen Sinn an der Stelle.

Wenn, dann müsste es eher so aussehen:
Code:
iptables  -A FORWARD -s 192.168.1.10 -i eth0 -o tun0 -j REJECT
Um zum Beispiel alles was von 192.168.1.10 kommt und nach tun0 will zurückzuweisen.

Oder z.B. alles zurückweisen außer was von 192.168.1.10 kommt:
Code:
iptables -A FORWARD  -s 192.168.1.10   -i eth0 -o tun0 -j ACCEPT
iptables -A FORWARD  -i eth0 -o tun0 -j REJECT
 
andy_m4 schrieb:
Nat? MASQUERADE? Das macht ja nun gar keinen Sinn an der Stelle.

Hatte gedacht das Nat sei nötig, weil vor der IPFire noch der Router ist.

Also
Code:
Router <-- red0 --> IPFire <-- green0 --> Client
Bei der IPFire heißen die Schnittstellen anders und zwar red0 und green0, wobei green0 das LAN wäre.

Denke eth0 müsste dann green0 (wo der Client drin ist) entsprechend heißen?
Code:
iptables  -A FORWARD -s 192.168.1.10 -i green0 -o tun0 -j ACCEPT

Allerdings funktioniert das nicht, es lädt keine Seite dann. Habe es auch mit -i red0 und weglassen von -i versucht, gleiches Ergebnis:(
 
Pello schrieb:
Allerdings funktioniert das nicht, es lädt keine Seite dann. Habe es auch mit -i red0 und weglassen von -i versucht, gleiches Ergebnis:(
Hm. Vielleicht sollte ich mir erstmal einen Überblick verschaffen.

Was ist denn die Ausgabe auf den IPFire-Rechner von
Code:
route -n
und
Code:
iptables -L
?
 
Vielen Dank für deine Hilfe!

EintragDestinationGatewayGenmaskFlagsMetricRefUseIface
10.0.0.010.44.83.5128.0.0.0UG000tun0
20.0.0.0192.168.2.10.0.0.0UG20200red0
310.44.83.110.44.83.5255.255.255.255UGH000tun0
410.44.83.50.0.0.0255.255.255.255UH000tun0
5128.0.0.010.44.83.5128.0.0.0UG000tun0
691.150.15.5192.168.2.1255.255.255.255UGH000red0
7192.168.2.00.0.0.0255.255.255.0U20200red0
8192.168.1.00.0.0.0255.255.255.0U000green0
Das Netzwerk 192.168.2.0 ist vom Router vor der IPFire.


Hoffe das ist so gut lesbar. Ist frisch nach dem boot, noch nichts mit IPTables geändert.
Chain INPUT (policy DROP)
target prot opt source destination
BADTCP tcp -- anywhere anywhere
CUSTOMINPUT all -- anywhere anywhere
P2PBLOCK all -- anywhere anywhere
GUARDIAN all -- anywhere anywhere
OVPNBLOCK all -- anywhere anywhere
IPTVINPUT all -- anywhere anywhere
ICMPINPUT all -- anywhere anywhere
LOOPBACK all -- anywhere anywhere
CAPTIVE_PORTAL all -- anywhere anywhere
CONNTRACK all -- anywhere anywhere
DHCPGREENINPUT all -- anywhere anywhere
GEOIPBLOCK all -- anywhere anywhere
IPSECINPUT all -- anywhere anywhere
GUIINPUT all -- anywhere anywhere
WIRELESSINPUT all -- anywhere anywhere ctstate NEW
OVPNINPUT all -- anywhere anywhere
TOR_INPUT all -- anywhere anywhere
INPUTFW all -- anywhere anywhere
REDINPUT all -- anywhere anywhere
POLICYIN all -- anywhere anywhere

Chain FORWARD (policy DROP)
target prot opt source destination
BADTCP tcp -- anywhere anywhere
TCPMSS tcp -- anywhere anywhere tcp flags:SYN,RST/SYN TCPMSS clamp to PMTU
CUSTOMFORWARD all -- anywhere anywhere
P2PBLOCK all -- anywhere anywhere
GUARDIAN all -- anywhere anywhere
IPSECBLOCK all -- anywhere anywhere policy match dir out pol none
OVPNBLOCK all -- anywhere anywhere
OVPNBLOCK all -- anywhere anywhere
IPTVFORWARD all -- anywhere anywhere
LOOPBACK all -- anywhere anywhere
CAPTIVE_PORTAL all -- anywhere anywhere
CONNTRACK all -- anywhere anywhere
GEOIPBLOCK all -- anywhere anywhere
IPSECFORWARD all -- anywhere anywhere
WIRELESSFORWARD all -- anywhere anywhere ctstate NEW
FORWARDFW all -- anywhere anywhere
UPNPFW all -- anywhere anywhere ctstate NEW
REDFORWARD all -- anywhere anywhere
POLICYFWD all -- anywhere anywhere
ACCEPT all -- badum-PC.localdomain anywhere

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
CUSTOMOUTPUT all -- anywhere anywhere
P2PBLOCK all -- anywhere anywhere
IPSECBLOCK all -- anywhere anywhere policy match dir out pol none
LOOPBACK all -- anywhere anywhere
CONNTRACK all -- anywhere anywhere
DHCPGREENOUTPUT all -- anywhere anywhere
IPSECOUTPUT all -- anywhere anywhere
OUTGOINGFW all -- anywhere anywhere
POLICYOUT all -- anywhere anywhere

Chain BADTCP (2 references)
target prot opt source destination
RETURN all -- anywhere anywhere
PSCAN tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,PSH,URG
PSCAN tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,SYN,RST,ACK,URG
PSCAN tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,SYN,RST,PSH,ACK,URG
PSCAN tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN
PSCAN tcp -- anywhere anywhere tcp flags:SYN,RST/SYN,RST
PSCAN tcp -- anywhere anywhere tcp flags:FIN,SYN/FIN,SYN
PSCAN tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,PSH,ACK,URG/NONE
NEWNOTSYN tcp -- anywhere anywhere tcp flags:!FIN,SYN,RST,ACK/SYN ctstate NEW

Chain CAPTIVE_PORTAL (2 references)
target prot opt source destination

Chain CAPTIVE_PORTAL_CLIENTS (0 references)
target prot opt source destination
RETURN udp -- anywhere anywhere udp dpt:domain limit: up to 3kb/s burst 1mb mode srcip
RETURN tcp -- anywhere anywhere tcp dpt:domain limit: up to 3kb/s burst 1mb mode srcip
DROP all -- anywhere anywhere

Chain CONNTRACK (3 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere ctstate ESTABLISHED
DROP all -- anywhere anywhere ctstate INVALID
ACCEPT icmp -- anywhere anywhere ctstate RELATED
ACCEPT all -- anywhere anywhere ctstate RELATED helper match "sip"
ACCEPT all -- anywhere anywhere ctstate RELATED helper match "h323"
ACCEPT tcp -- anywhere anywhere ctstate RELATED helper match "ftp" tcp dpts:1024:65535
ACCEPT all -- anywhere anywhere ctstate RELATED helper match "tftp"
ACCEPT all -- anywhere anywhere ctstate RELATED helper match "irc"

Chain CUSTOMFORWARD (1 references)
target prot opt source destination

Chain CUSTOMINPUT (1 references)
target prot opt source destination

Chain CUSTOMOUTPUT (1 references)
target prot opt source destination

Chain DHCPBLUEINPUT (0 references)
target prot opt source destination

Chain DHCPBLUEOUTPUT (0 references)
target prot opt source destination

Chain DHCPGREENINPUT (1 references)
target prot opt source destination
DHCPINPUT all -- anywhere anywhere

Chain DHCPGREENOUTPUT (1 references)
target prot opt source destination
DHCPOUTPUT all -- anywhere anywhere

Chain DHCPINPUT (1 references)
target prot opt source destination
ACCEPT udp -- anywhere anywhere udp spt:bootpc dpt:bootps
ACCEPT tcp -- anywhere anywhere tcp spt:bootpc dpt:bootps

Chain DHCPOUTPUT (1 references)
target prot opt source destination
ACCEPT udp -- anywhere anywhere udp spt:bootps dpt:bootpc
ACCEPT tcp -- anywhere anywhere tcp spt:bootps dpt:bootpc

Chain FORWARDFW (1 references)
target prot opt source destination

Chain GEOIPBLOCK (2 references)
target prot opt source destination

Chain GUARDIAN (2 references)
target prot opt source destination

Chain GUIINPUT (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:snpp

Chain ICMPINPUT (1 references)
target prot opt source destination
ACCEPT icmp -- anywhere anywhere icmp echo-request

Chain INPUTFW (1 references)
target prot opt source destination

Chain IPSECBLOCK (2 references)
target prot opt source destination

Chain IPSECFORWARD (1 references)
target prot opt source destination

Chain IPSECINPUT (1 references)
target prot opt source destination

Chain IPSECOUTPUT (1 references)
target prot opt source destination

Chain IPTVFORWARD (1 references)
target prot opt source destination

Chain IPTVINPUT (1 references)
target prot opt source destination

Chain LOG_DROP (0 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 10/min burst 5 LOG level warning
DROP all -- anywhere anywhere

Chain LOG_REJECT (0 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 10/min burst 5 LOG level warning
REJECT all -- anywhere anywhere reject-with icmp-port-unreachable

Chain LOOPBACK (3 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
DROP all -- 127.0.0.0/8 anywhere
DROP all -- anywhere 127.0.0.0/8

Chain NEWNOTSYN (1 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 10/min burst 5 LOG level warning prefix "DROP_NEWNOTSYN "
DROP all -- anywhere anywhere /* DROP_NEWNOTSYN */

Chain OUTGOINGFW (1 references)
target prot opt source destination

Chain OVPNBLOCK (3 references)
target prot opt source destination
RETURN icmp -- anywhere anywhere ctstate RELATED

Chain OVPNINPUT (1 references)
target prot opt source destination
ACCEPT udp -- anywhere anywhere udp dpt:openvpn

Chain P2PBLOCK (3 references)
target prot opt source destination

Chain POLICYFWD (1 references)
target prot opt source destination
ACCEPT all -- ipfire.localdomain/24 anywhere
ACCEPT all -- anywhere anywhere policy match dir in pol ipsec
ACCEPT all -- anywhere anywhere
LOG all -- anywhere anywhere limit: avg 10/min burst 5 LOG level warning prefix "DROP_FORWARD "
DROP all -- anywhere anywhere /* DROP_FORWARD */

Chain POLICYIN (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere policy match dir in pol ipsec
ACCEPT all -- anywhere anywhere
LOG all -- anywhere anywhere limit: avg 10/min burst 5 LOG level warning prefix "DROP_INPUT "
DROP all -- anywhere anywhere /* DROP_INPUT */

Chain POLICYOUT (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
DROP all -- anywhere anywhere /* DROP_OUTPUT */

Chain PSCAN (7 references)
target prot opt source destination
LOG tcp -- anywhere anywhere limit: avg 10/min burst 5 /* DROP_TCP PScan */ LOG level warning prefix "DROP_TCP Scan "
LOG udp -- anywhere anywhere limit: avg 10/min burst 5 /* DROP_UDP PScan */ LOG level warning prefix "DROP_UDP Scan "
LOG icmp -- anywhere anywhere limit: avg 10/min burst 5 /* DROP_ICMP PScan */ LOG level warning prefix "DROP_ICMP Scan "
LOG all -f anywhere anywhere limit: avg 10/min burst 5 /* DROP_FRAG PScan */ LOG level warning prefix "DROP_FRAG Scan "
DROP all -- anywhere anywhere /* DROP_PScan */

Chain REDFORWARD (1 references)
target prot opt source destination

Chain REDINPUT (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp spt:bootps dpt:bootpc
ACCEPT udp -- anywhere anywhere udp spt:bootps dpt:bootpc

Chain TOR_INPUT (1 references)
target prot opt source destination

Chain UPNPFW (1 references)
target prot opt source destination

Chain WIRELESSFORWARD (1 references)
target prot opt source destination

Chain WIRELESSINPUT (1 references)
target prot opt source destination

Edit: Korrektur/vervollständigung.
 
Zuletzt bearbeitet:
Jetzt muss ich glatt noch mal nachfragen, was Du eigentlich vorhast (weil auch in der Routing-Tabelle gar kein tun0 Adapter auftaucht).

Willst Du ein VPN haben sie wie es ganz klassisch und einfach gemeint ist, nämlich dass man zwei private Netzwerke miteinander verbindet. Oder geht es bei dem VPN eher um solche Sachen wie: Man verbindet sich via VPN zu einem Anonymisierungs-Provider, um darüber quasi "anonym" im Internet zu surfen (um z.B. auch solche Sachen wie "Dieses Video ist in ihrem Land nicht verfügbar" zu umgehen)?
 
andy_m4 schrieb:
Jetzt muss ich glatt noch mal nachfragen, was Du eigentlich vorhast (weil auch in der Routing-Tabelle gar kein tun0 Adapter auftaucht).
Da ist mir ein Fehler unterlaufen :( Habe meinen vorigen Post aktualisiert, jetzt ist es richtig.

andy_m4 schrieb:
Willst Du ein VPN haben sie wie es ganz klassisch und einfach gemeint ist, nämlich dass man zwei private Netzwerke miteinander verbindet. Oder geht es bei dem VPN eher um solche Sachen wie: Man verbindet sich via VPN zu einem Anonymisierungs-Provider, um darüber quasi "anonym" im Internet zu surfen (um z.B. auch solche Sachen wie "Dieses Video ist in ihrem Land nicht verfügbar" zu umgehen)?
"Anonymisierung" trifft es ganz gut.
 
Zurück
Oben