Lil’ bit: Redirecting traffic out a given interface

2009/02/25 16:23:00
Print Friendly

This is a relatively simple trick, but one that I thought was rather clever.

I needed to SSH into a target server ( that only allowed connections from a specific IP address ( I knew that the system holding that specific IP address was down, yet I still needed to SSH into the target.

To further complicate matters, I did not have physical access to the target network at the time. But, I did have remote access (and root) to another Linux box on the network.


So, all I needed to do was change the IP address of my one good box to the one expected by the target system, but if I changed the IP address on the main interface, then I would disconnect myself.

Enter virtual interfaces and routing.

I created a new virtual interface with ifconfig (assuming is the IP we want to come from):

/sbin/ifconfig eth0:1

This does not, however, mean that my SSH connection will come from this address, so I needed to change the routing table (assuming is what we want to connect to):

/sbin/route add -host eth0:1

Now, I will effectively be coming from my new interface when I connect to the target server.

AHA! It works!

2007/08/17 00:02:00
Print Friendly

As usual, when I have some time off, I tinker with my network and tend to break something.

I decided that I could let my wireless router rest a bit by turning off its gateway functionality, thereby accepting it into my LAN and telling it not to treat the other side like the wilds of the Internet. This means it wasn’t translating addresses for me anymore. No NAT.

This is all well and good, but now the network on the other side of that wireless router needs to be known to my central Linux router. Hmmm!

So, I typed in

sudo /<span>sbin</span>/ip route add via dev eth2

where is the wireless network and is the tiny (2 connection) network between the Linux router and the wireless router.

This made things work great, but I wondered how to ensure that this route was added at each reboot.

In CentOS 3, this information is stored in the /etc/sysconfig/static-routes file like so:

any net netmask gw dev eth2

This syntax is used by the



Well, off to bed.