Koozali.org: home of the SME Server

Can anyone help me with some iptables rules?

nick

Can anyone help me with some iptables rules?
« on: May 18, 2005, 12:24:25 PM »
I have two SME servers that used to talk via CIPE (it's a lot easier to get through double NAT than IPSEC/FreeSWAN) recently I did a clean install of their main site, as the machine had been overcustomized, and was pretty much unadministratable.

The other server is still up and running, and I get no error messages on that side, on the new side though, I get a connection refused error from the cipe daemon, which means that it can't talk to the other side..

The problem obviously isn't in the output chain, but when I do a ping I can watch the Incoming_UDP chain(the type of packets CIPE uses for communication) incrementing, nothing else does so though.

I'm using 6.0.1, and the networks are like this:
new server..
Internally 10.32.8.x
externally 192.168.5.x
Cipe interface 192.168.190.1 port 6060

old server
Internally 10.32.7.x
externally 192.168.6.x
cipe 192.168.190.2           port 6060

routes are all in place and correct, I've tried adding rules allowing traffic from and to the cipe ports (udp and port specified, and also less picky), and even letting in any udp traffic on port 6060, but it doesn't change anything. I continue to watch the connections go smack onto the wall that says Incomining_UDP_2609 all * * 0.0.0.0 !192.168.5.2 (the external LAN interface)..

Any idea what I need to let through exactly?

BTW, the old server is in desperate need of an Upgrade, but i really don't want to do it until I get this business figured out.

Offline arne

  • *****
  • 1,116
  • +0/-4
Can anyone help me with some iptables rules?
« Reply #1 on: May 19, 2005, 05:42:34 PM »
Problem: I know nothing about Cipe exept for a short read trough at their homepage.

Possily not so smart to answer a question with just a new question, but the thing is that configuring Linux firewalls is, as I see it, generally a question of understanding the nature of the trafic that floats trough it. I think when the question "how is the nature of the trafic flow without a firewall" than it is allways possible to desingn and verify a firewall that will let that trafic trough.

First off all: What do they speakt about, those two sme servers ? What kind of trafick is floating to and from via the tunnel ?

Second: How does it reaaly work ? Is it a some kind of klient server solution where the one sme server is the server and the other is the client ? (Or is it an arrangement where they both are equal, or does it work in a way that both are clients and servers ?)

All the ip adresses in the description above are ip's in the internal ip range. Should this encrypted tunnel run trough a lan environment only, or should it also pass via internet ?

Are the two sme servers set up as gateways or as standallone servers ? If it is gateway servers why do the two gateways have internal ip's on each side of the gateway ?

By the way if you don't have it installed allready suggest you download and install RedHat 7.3 iptraf (trafic monitor) and nmap (Portscanner.)
......

nick

Can anyone help me with some iptables rules?
« Reply #2 on: May 23, 2005, 10:54:44 AM »
Quote from: "arne"
Problem: I know nothing about Cipe exept for a short read trough at their homepage.

It's not a super difficult system, basically, it creates its own interface cipcbx on your external ethernet connection eth1 usually.. this connection has its own IP and subnet (192.168.190.x in my case). These interfaces send and recieve UDP packets with the encrypted data destined for the internal networks. They're both listening on the external interfaces on port 6060..

Obviously it's not quite that simple, but that's the basic gist of things..
Quote

Possily not so smart to answer a question with just a new question, but the thing is that configuring Linux firewalls is, as I see it, generally a question of understanding the nature of the trafic that floats trough it. I think when the question "how is the nature of the trafic flow without a firewall" than it is allways possible to desingn and verify a firewall that will let that trafic trough.

Without a firewall, the traffic would originate on the internal machine, a route would tell it to head out through the cipcb0 interface, where it's encapsulated and sent in a UDP packet to port 6060 on the other external interface, where the cipd is listening, and will recieve the UDP packet and unpack it and send it on to it's final internal destination.
Quote



First off all: What do they speakt about, those two sme servers ? What kind of trafick is floating to and from via the tunnel ?


Apart from the cipe traffic, and ssh, there is no permanent connection between the two. The tunnel usually has fairly unimportant traffic, the client mainly uses it to send print jobs to printers in their other building (it's a couple of kilometers away).
Quote


Second: How does it reaaly work ? Is it a some kind of klient server solution where the one sme server is the server and the other is the client ? (Or is it an arrangement where they both are equal, or does it work in a way that both are clients and servers ?)


As far as I can tell, both sides can initiate the connection by doing a connect, then a key exchange. Either side can be a client or server.
Quote


All the ip adresses in the description above are ip's in the internal ip range. Should this encrypted tunnel run trough a lan environment only, or should it also pass via internet ?


The addresses are internal because that's where my problems start, the connections between the two work, the traffic is arriving from the internet without an issue, it's just being stopped before it can be unpacked by the cipd (which would be on the inside of the eth1 interface, if I was to draw a diagram..)
Quote


Are the two sme servers set up as gateways or as standallone servers ? If it is gateway servers why do the two gateways have internal ip's on each side of the gateway ?


They're gateways, with routers that make the external connections, which is why I'm not using freeSwan, as it has real problems with double NATting, cipe doesn't really care.
Quote


By the way if you don't have it installed allready suggest you download and install RedHat 7.3 iptraf (trafic monitor) and nmap (Portscanner.)


I've done a bit of tcpdumping on the cipe and external interface, and I've done a netstat on both sides, which show port 6060 open and established on both sides, my problem is that the firewall grabs the incoming UDP packets and discards them.. I was thinking about having iptables be a bit more verbose when discarding the packets, but I honestly don't know how.

BTW, thanks for the reply, sorry I didn't reply earlier, I've been rather busy :D

Offline arne

  • *****
  • 1,116
  • +0/-4
Can anyone help me with some iptables rules?
« Reply #3 on: May 24, 2005, 01:04:24 AM »
Ok, I understand that this "mechanism" can set up a "fixed working as lan conecction" via internet ?!

By the way, thanks for a extensive and interesting description.

From a firewalling point of view it looks like it is only a question about setting up a "two way or bidirectional UDP port 6060 server mechanism".

The trafic out via the forwarding chain should normally not be a problem, because normally on most firewall this trafic will be open.

Then it will be a question of forwarding the udp 6060 packets to the proper server and eventually, if required, also open a port for that (Don't know if sme gateway will allow this trafic as default.)

One problem - its allways a problem to modify an existing firewall withouth a complete overview of how it "looks", but it could still be tried.

The rule modification must be applied to the to of the rule stack and not at the bottom, where they might have no effect.  

You could try something like this (.2 is the server):
(The forwarding)

iptables -t nat -I PREROUTING -i eth0 -p udp --dport 6060 -j DNAT --to 10.0.0.2:6060

And if required also this:
(The opening of the firewall forward chain)

iptables -I FORWARD -i eth0 -p udp --dport 6060 -j ACCEPT

(-A append, at the bottom, -I, insert at the top of the stack.)

If you just apply the command as a extra 2 line script, the changes will be gone as soon as you reboot your server so there is no big risk. (But console access is always a good idea.)

Please leave a message if it works in any way ..

Best reg Arne.
......

nick

Can anyone help me with some iptables rules?
« Reply #4 on: May 25, 2005, 12:40:55 PM »
I'm leaving a message, but it's not working yet :)

I gave it a try yesterday, but ran into some other larger problems which I needed to get resolved beforehand. I got around to actually verifying where the  packets stop, as always it's on the Inbound_UDP rule where it denys anything not destined for eth1 192.168.5.2.

Sigh.