4

We have a CentOS server with 2 ethernet adapters. Both of these adapters have access to the internet and both can be used to connect to remote sites.

Is there a way to know which ethernet adapter will be used when connecting to an FTP server or connecting via SSH to another server? If so, is there a way to force it to use a particular adapter without disabling any?

lfboulanger
  • 2,140
  • 2
  • 17
  • 20

2 Answers2

3

Perhaps you can set up a special route for the servers you intend to connect to? Have a look at the route command, or the "ip route" command.

EDIT: This seems to contain an example of what I'm saying: http://www.cyberciti.biz/faq/howto-linux-configuring-default-route-with-ipcommand/

Specifically:

Type the following command to sent all packets to the local enter code herenetwork 192.168.1.0 directly through the device eth0:, enter

ip route add 192.168.1.0/24 dev eth0
Jonatan
  • 2,734
  • 2
  • 22
  • 33
1

For ssh, you can use the BindAddress ssh_config option. You can specify it on the command line with the -o option.

mitchnull
  • 6,161
  • 2
  • 31
  • 23
  • Yup, you can use clients that allow specifying which source address (or interface) to bind to, but you probably also need to fool around with ip route a bit and specify different routes based on source address... either default route for the whole internet, or just specific routes for some servers you want to connect to. – Torp Apr 11 '12 at 18:13