[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

How do I add a gateway to eth1?



 I need help figuring out how to add a second gateway to eth1, so that "ping 
-I eth1 www.google.com" works as well as through the default gw on eth0

I need it because I'm I have a server with 2 NICs: eth0 is an external IP, 
eth1 is connected to the private LAN  (192.168.0.) and this server is running 
Linux-VServer, which is using another IP on eth1 (aliased). Once I'm "inside" 
the vserver, I am not able to ping or connect to the outside network in any 
way. I talked to some of the VServer folks, and they told me what's happening 
is traffic destined for the outside - let's say to ftp.us.debian.org - is 
pushed out of eth1 - because this VServer is running on an eth1alias, and 
using a 192.168.0. address - which is the network eth1 is on. However, when 
the host system has a default gateway on the external NIC (eth0) and network, 
the traffic going out through eth1 is not able to reach the external gateway 
(of course) which is 12.171.-something. I forgot if they said it was because 
traffic going out of eth1 had not gateway assigned at all, or if it was 
because they were trying to get to the external gateway.

The thing is, on our LAN network 192.168.0.1 we have a LAN router/gateway, so 
if I coudl assign that gateway to eth1, then the traffic headed for external 
destinations like debian.org or google.com could just pass out through the 
usual LAN gateway and be fine. BUt I can't figure out how to do that.

I've been searching around the web and I've been told that various 
combinations of this might work:

route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.0.23 eth1

route add default gw 192.168.0.23 metric 2 eth1

iptables -t nat -I POSTROUTING -s $VSERVER_NETZ  ! -d $VSERVER_NETZ -j SNAT 
--to $EXT_IP
(which I converted to:)
iptables -t nat -I POSTROUTING -s 192.168.0.0  ! -d 192.168.0.0 -j SNAT --to 
12.171.179.96

I've tried all the above (not at the same time) but none of them worked.

BTW I also tried adding a gateway to eth1 in the /etc/network/interfaces file. 
Not only did that not solve the problem, but it also caused me to lno longer 
be able to ssh in from the outside network through eth0.

Does anyone know how to set this up?

Thanks,

	JW

-- 

----------------------
System Administrator - Cedar Creek Software http://www.cedarcreeksoftware.com
http://jwadmin.blogspot.com/



Reply to: