@David Schwartz is correct. But you also need to make sure the subnet masks are set correctly. In your case above, you want to set the subnet masks of both interfaces to 255.255.255.0.
Your original question stated there was a LAN behind both interfaces (not the "Internet") so the above is correct for that situation.
If you want the machine to forward traffic between subnets (subnet = LAN for the purposes of this) you need to make sure you echo 1
to /proc/sys/net/ipv4/ip_forward
- and also make sure your iptables
is set to not filter anything. If you don't do this, machines behind both LANs can reach the Linux box but not the other LAN.
Now, you seem to want to have an interface reach both the Internet and a LAN. It can be done if the LAN in question has a router and you know that router's IP address. You would set the Linux box's default gateway to the IP and subnet of the router. (If there is no router to the Internet on any LAN, then you don't set a default gateway at all.)
What's happening when you "restart eth1" is likely that eth1 is getting an IP via DHCP from a router and your IP addresses and default route assignments are actually changing when you do that.
If your DHCP is set correctly on the LAN with the router, with an IP reservation or similar, you can probably just let DHCP take care of it.
Thank you for the reply. I really appreciate it. If I connect to LAN on eth0 and WAN (Internet) on eth1, I cannot browse or use any Internet related software. If I disconnect from LAN on eth0 and restart eth1, I can browse and use software related to Internet. Why would this happen? – None – 2013-02-02T03:56:36.900
Do you have a default route (gateway) on the
eth0
interface? You shouldn't. – David Schwartz – 2013-02-02T04:35:42.797