Toon posts:

[iptables+iproute]

Pagina: 1
Acties:

Verwijderd

Topicstarter
Ben al een paar dagen aan het nadenken over een firewall configuratie + subnet routing via een linux box die ik hier op het werk heb.

We hebben een SDSL verbinding met 8 subnet IP adressen:
code:
1
2
3
4
5
6
7
8
IP adres van de modem = 62.78.33.128
IP adres van de firewall = 62.78.33.129 (eth1)
IP adres van de interne mail server (die dus achter de firewall staat) = 
62.78.33.140 (interne ip adres = 192.168.1.10)
IP adres van de interne apache server = 62.78.33.142 (interne ip adres = 
192.168.1.111)

Het interne IP adres van de firewall = 192.168.1.110 (eth0)


De setup van iptables moet als zodanig zijn dat aanvragen op het ip adres 62.78.33.140 worden geforward naar het interne ip nummer 192.168.1.10 (beide op poort 25)

daar had ik dus de volgende configuratie voor bedacht:
code:
1
2
3
4
5
6
7
8
9
#  Rule 1(NAT)
# 
$IPTABLES -t nat -A PREROUTING  -p tcp  --source-port 25  -d 62.78.33.129 
--destination-port 25 -j DNAT --to-destination 192.168.1.10:25 
$IPTABLES -t nat -A OUTPUT  -p tcp  --source-port 25  -d 62.78.33.129 
--destination-port 25 -j DNAT --to-destination 192.168.1.10:25 
$IPTABLES -t nat -A POSTROUTING -o eth1 -p tcp  --source-port 25  -d 192.168.1.10
 --destination-port 25 -j SNAT --to-source 62.78.33.140:25 
#


Ik vroeg mij eigenlijk of dit uberhaupt gaat werken? Als ik er zo naar kijk lijkt het mij niet echt logisch..

de route table ziet er als volgt uit:
code:
1
2
3
4
5
6
7
Kernel IP routing table
Destination     Gateway         Genmask      Flags  Metric   Ref  Use Iface
192.168.1.0        *           255.255.255.0   U      0      0     0   eth0
62.59.33.0         *           255.255.255.0   U      0      0     0   eth1
127.0.0.0          *           255.0.0.0       U      0      0     0   lo
default         192.168.1.110  0.0.0.0         UG     0      0     0   eth0
0.0.0.0         62.78.33.128   0.0.0.0         UG     1      0     0   eth1


En weet iemand misschien of ik aan die eth1 interface ook de ip adressen moet hangen van de mailserver en de interne apache server? Of wordt dat afgehandeld door de routing table? (virtual IP's?)

Ik heb express niet de hele iptables config hier geplaatst, omdat die nogal lang is, ik kan hem echter wel posten mocht daar behoefte aan zijn. Ik probeer dit op te zetten om wat meer inzicht te krijgen in het hele routing/firewall gebeuren van iptables/iproute, lijkt mij zeer krachtig.

Verwijderd

Topicstarter
Het is me gelukt :)

hier een script gedownload:
http://projectfiles.com/firewall/

Vervolgens mijn netwerkkaart voorzien van 2 extra IP adressen (Virtual IP's)
code:
1
2
ip a a <public IP adres internal server 1>/24 b 62.59.33.255 dev eth1 label eth1:0
ip a a <public IP adres internal server 2>/24 b 62.59.33.255 dev eth1 label eth1:1


Vervolgens het script aangepast:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
PERMIT=""

INTERNAL_INTERFACES="eth0"

DENY_OUTBOUND=""
ALLOW_INBOUND=":192.168.1.10:21/tcp :192.168.1.10:82/tcp :192.168.1.10:25
 :192.168.1.111:80/tcp 53"
BLACKLIST=""
STATIC_INSIDE_OUTSIDE="192.168.1.10:<public IP adres internal server 1>
 192.168.1.111:<public IP adres internal server 2>"
PORT_FORWARDS=""
PORT_FWD_ALL="no"
PORT_FWD_ROUTED_NETWORKS="yes"
ADDITIONAL_ROUTED_NETWORKS=""
TRUST_ROUTED_NETWORKS="yes"
SHARED_INTERNAL="yes"
FIREWALL_IP=""
TRUST_LOCAL_EXTERNAL_NETWORKS="no"
DMZ_INTERFACES=""
NAT_EXTERNAL="yes"
ADDITIONAL_NAT_INTERFACES=""
IGNORE_INTERFACES=""
LOGGING="yes"
REQUIRE_EXTERNAL_CONFIG="no"


Dat werkt, hoop dat iemand er iets aan heeft :)