Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
virt ip routing question
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
corey_s
Apprentice
Apprentice


Joined: 29 Jun 2003
Posts: 264

PostPosted: Thu May 12, 2011 6:23 am    Post subject: virt ip routing question Reply with quote

I've created an eth0:0 using ifconfig. I now need, say, telnet/ssh to use the aliased eth0:0 ip rather than the eth0 ip when accessing certain remote hosts (due to hosts.allow/deny rules)...

How do I force a particular ssh or telnet through a particular iface?

Thanks!
Back to top
View user's profile Send private message
Takkun
n00b
n00b


Joined: 07 May 2011
Posts: 15

PostPosted: Thu May 12, 2011 8:54 pm    Post subject: Reply with quote

Just a guess, but for ssh, wouldn't using BindAddress in ssh_config or ~/.ssh/config or -b inline be what you are after?
Back to top
View user's profile Send private message
AngelKnight
Tux's lil' helper
Tux's lil' helper


Joined: 14 Jan 2003
Posts: 126

PostPosted: Mon May 16, 2011 2:08 am    Post subject: Reply with quote

Hi,

With appropriately recent iproute2 and kernel [1] this can be done on a L3-basis (that is, on an IP-by-IP basis).

Code:
# /sbin/ip route add ${DEST} via ${NH} src ${SRC_IP_YOU_WANT_TO_USE}


For example, assume the following configuration:

Code:
# /sbin/ip addr show

[...]

2: eth0: [...]
  inet 192.168.1.4/24 brd 192.168.1.255 scope global eth0
  inet 192.168.1.5/32 brd 192.168.1.5 scope global eth0:1

# /sbin/ip route show

[...]

192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.4
default via 192.168.1.1 dev eth0


Assuming your special remote host (which, for the sake of argument will really see 192.168.1.4 or 192.168.1.5, and not a SNATted or MASQUERADEd address) is 172.19.4.1, the correct route statement is:

Code:
# /sbin/ip route add 172.19.4.1 via 192.168.1.1 src 192.168.1.5


Note that this causes all traffic destined for 172.19.4.1 to source from 192.168.1.5 instead of 192.168.1.4. All of this is being done within the FIB in a manner which doesn't pay attention above layer 3.

There is more than one way to do this. I suspect more people are familiar with doing this with iptables rather than with RPDB.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum