You are not logged in.

#1 2016-11-28 03:52:00

billytv
Member
Registered: 2016-11-04
Posts: 2

How to binding destination IP to specific interface in dual network

Hi there,

I think the subject is little confusing, here's the details.

I have two network interface. eth0 and eth1, both accessible to internet.

How ip route looks like
default via 192.168.1.1 dev eth0
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.21
192.168.99.0/24 dev eth1  proto kernel  scope link  src 192.168.99.21

All traffic route to eth0(gateway: 192.168.1.1) by default,  I want to make specific website or IP address route to eth1 (gateway: 192.168.99.1), how can I do that?

Thank you.

Offline

#2 2016-11-28 08:23:48

ayekat
Member
Registered: 2011-01-17
Posts: 1,589

Re: How to binding destination IP to specific interface in dual network

Assuming your gateway for the 192.168.99.0/24 subnet is 192.168.99.1, I would simply go with

ip route add <ip> via 192.168.99.1 dev eth1

Or does that not work? What have you tried so far?


pkgshackscfgblag

Offline

#3 2016-11-28 09:07:13

billytv
Member
Registered: 2016-11-04
Posts: 2

Re: How to binding destination IP to specific interface in dual network

ayekat wrote:

Assuming your gateway for the 192.168.99.0/24 subnet is 192.168.99.1, I would simply go with

ip route add <ip> via 192.168.99.1 dev eth1

Or does that not work? What have you tried so far?


Thanks for reply, I just solved by creating a new route table.


ip link set eth1 up
ip addr add 192.168.99.21/24 broadcast 192.168.99.255 dev eth1
ip route add table rt1 default via 192.168.99.1
ip rule add to <ip> table rt1

Offline

Board footer

Powered by FluxBB