My home server has two interfaces named eth0 and eth1. eth0 is connected directly to an incoming WAN port, so the gateway for eth0 is determined depending on the ISP's DHCP server. eth1 is connected to my router, which is connected to another WAN port.
Below is the output of netstat -rn
(111.111.111.126 is a mock public address):
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 111.111.111.126 0.0.0.0 UG 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
111.111.111.126 0.0.0.0 255.255.255.128 U 0 0 0 eth0
I want to be able to choose an interface for the outgoing connections freely, but don't know how. curl www.google.com --interface eth1
should connect to www.google.com via eth1, it fails in the current configuration. route add default gw 192.168.0.1
fixes that, but then curl www.google.com --interface eth0
breaks.