You are not logged in.
I have two network interfaces (eth0 and eth1) with separate IP addresses on the same subnet. All outgoing traffic uses eth0 regardless of the interface the incoming traffic came in on.
I assume the outgoing packets still have the correct source IP address (not always eth0's), and I'd like the packets to go out on the interface with the corresponding IP address.
I think I have half the solution to my problem:
http://www.novell.com/support/viewConte … Id=7000318
The other half is that my IPs are dynamic, so ddclient could change my IPs and then the routing would be invalid.
Last edited by MindlessXD (2009-02-10 07:06:16)
Offline
You might want to talk a look at this: http://wiki.archlinux.org/index.php/NAT … connection. This is probably not what you want, but it may help.
My 5 node 9 CPU cluster: www.amenrecluster.com
OS: Arch Linux
Machines:Fujitsu T4210 and IBM eServer xSeries 335
Offline
A while back I wrote myself a script to setup a routing table for load-balancing between two interfaces (not what you want) but here are some bash-functions that I wrote that may help you getting the dynamic addresses:
#arg0 = ifdev
get_netmask ()
{
ifconfig $1 | grep -m 1 'Mask' | awk '{print $4}' | awk -F":" '{print $2}'
}
#arg0 = ifdev
get_ip ()
{
ifconfig $1 | grep -m 1 'inet addr' | awk '{print $2}' | awk -F":" '{print $2}'
}
#arg0 = ifdev
get_gateway ()
{
route -n | grep $1 | sed "s/default/0.0.0.0/g" | sed "s/^.*:.*$//g" | grep "^0.0.0.0" | awk '{print $2}'
}
#arg0 = ifdev arg1 = ifdev's IP
get_cider_mask ()
{
ip route | grep "$1.*src *$2" | awk '{print $1}'
}
From here you could go and write yourself a script.
m.
Last edited by mcover (2009-02-12 18:14:51)
Offline
I think this might be what you need:
http://wiki.archlinux.org/index.php/Con … rk#bonding
In love I believe and in Linux I trust
Offline
Setup custom route tables to be used depending on the iptables conntrack marks below
ip route flush table 1
ip rule del fwmark 101 table 1
ip route add table 1 default via <ETH0 IP ADDRESS>
ip rule add fwmark 101 table 1
ip route flush table 2
ip rule del fwmark 102 table 2
ip route add table 2 default via <ETH1 IP ADDRESS>
ip rule add fwmark 102 table 2
I'm not 100% sure if you can add a route via the interfaces IP address. This code has been modified from a box using 2 different ISP's so they have different upstream routers. You might need to replace the 'via' parts with 'src'
# Ensure traffic in one interface goes back out the same interface
iptables -t mangle -F PREROUTING
iptables -t mangle -A PREROUTING -j CONNMARK --restore-mark
iptables -t mangle -A PREROUTING -m mark ! --mark 0 -j ACCEPT
iptables -t mangle -A PREROUTING -i eth0 -m state --state NEW -j MARK --set-mark 101
iptables -t mangle -A PREROUTING -i eth1 -m state --state NEW -j MARK --set-mark 102
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline