RFC mania

January 22, 2010

I had to do an SNMP-related excercise for the Network Management Lab. We had to write a MIB(Message Information Base) for a firewall, to describe the filters and the rules of the firewall.
The MIB should be written in SNMPv2 SMI, so I read some RFCs.
I never liked the RFCs, and now I think that they’re even more disgusting. :P
Actually, I think that people who are involved with the whole process of the RFCs have serious personal problems(just kidding :P).
And to prove that I have a point, a friend of mine reminded me of an epic RFC.
RFC 1149, or IP over Avian Carriers!!!!
And that’s not the worst part. There’s more!
Some people did an actual implementation of the RFC!
I knew about the RFC but not that there was an “implementation”. :P
About 10 years ago.
Link 1 and Link 2.
The highlight(besides the pigeons ofcourse) was the source code, and the ping times.

Ok, in fact, I would say that the whole thing was fun and maybe interesting, but the RFCs are still disgusting. :P
Except for RFCs like these :P


January 19, 2010

Here’s the deal.
We have an OpenVPN server, part of a network, for instance network, and server’s IP
We connect to the OpenVPN server, using [b]UDP[/b], and a virtual [b]tap[/b] interface, let’s say, tap0.
After we’ve connected successfully with the vpn server, we run a dhcp client on the tap0 interface, and get an IP inside the network, let’s say
Along with the IP assignment, a new route will be added in the routing table, a route to the network, with no gateway(=link), through the tap0 interface.
Howerver, now we can’t contact the OpenVPN server. After the new route is added all of our packets to the VPN server, including the vpn packets, will be routed through the tap0 interface, and therefore VPN will stop working.
So, we add to the routing a table a route to the vpn server(, via our local gateway(for instance, through our physical network interface(for instance eth0).
Now, we can communicate with every other host inside the network over a VPN encrypted channel. But all of our connections to the VPN server will go through the unencrypted channel( route, bypassing the VPN/tap0 interafce).
But that’s not what we actually want.
Actually, we want to communicate with the VPN server over the VPN ‘tunnel’(and through tap0) for all the connections we make, except for the VPN connection.
That’s possible if we use iptables and iproute2.
We’ll mark the packets of the VPN connection using iptables(ie the packets using UDP, with destination address the VPN server, and destination port the port to which the server listens — port 1194 most likely).
iptables -t mangle -A OUTPUT -p udp -d --dport 1194 -j MARK --set-mark 1
Now, we’ll create a rule with iproute2, which will route the marked packets using a different routing table.
First we create the new table.
echo 200 vpn.out >> /etc/iproute2/rt_tables
We add the rule.
ip rule add fwmark 1 lookup vpn.out
And we add the route for the vpn server to the vpn.out table.
ip route add via dev eth0 table vpn.out
One last thing.
With this configuration, there’s a problem in the selection of the source address for the vpn packets to the vpn server. Because the marking and the change of the route is done later, VPN will see the “, no gateway, dev tap0″ route in the main routing table, and will select the tap0 IP as the source address, which is obviously wrong since we want to get routed through the eth0 interface(with IP for instance). This is fixed if we add the local option in our vpn client configutaion file, so that OpenVPN binds to that address and selects it correctly as the source address.
That’s it!
We send only vpn packets through the route, and everything else, including all other connections to the VPN server, are sent over vpn.
This ‘trick’ is very useful when you want to be able to ssh to the VPN server, but you want to prohibit ssh from IPs outside the local network.


Get every new post delivered to your Inbox.

Join 276 other followers