I have an Ubuntu-box as a gateway with two interfaces. The first one (eth0) is the internal network and has the following address:


The second one is connected to a router from an ISP, to which I don't have access! And, alas, it has as address... So I ended up choosing the following for eth1:


Then adding

route add eth1
ip route add default via dev eth1

But this only works if I change the IP of my gateway on eth0 to or something else. Is there a way to define the routing while keeping on my gateway, too?

PS: Yes, I could reconfigure my internal network to something else, but as there is a Windows-domain-server on it, I don't want to do that.

  • Cmon, this is Linux - there has to be another way! BTW usually I do have different subnets - just this time it would be very hard, as I have the PDC on the and more hardcoded IPs than I'd like to.
    – ineiti
    Sep 18 '14 at 5:26
  • i don't say you use iptables you implement this with ip route or route command. Sep 18 '14 at 10:10
  • 1
    The easiest fix, I think, is to insert a new, two-NIC system between eth1 and the ISP router, allocating a new (non-conflicting, this time!) network number for the eth1-NewSystem link. You won't be able to ping the ISP router from your system, but that's a minor issue. If you don't have a system to spare, you can probably accomplish the same thing with a VM running on the host. Sep 18 '14 at 20:06

The best solution would be to use two different subnets for your network, one for internal use and one for public/wan use, putting two interfaces in the same subnet will only cause you trouble. If you don't want to change the IP for the Windows DC, I suggest that you split the /24 to two /25, and use one for lower /25 for your internal net, and the upper /25 for your internet/wan connection.

  • Well, I have hardcoded IPs in the, so I can't put that easily to And I don't have access to the router, so I can't put that in the, neither :(
    – ineiti
    Sep 18 '14 at 5:27

I liked the answer from Mark Plotnick the best:

Insert a system with two NICs that hides the router from the gatewayor


Install a virtual machine on the gateway that is attached to the eth0 and an internal interface with another subnet. Then route all traffic through the internal interface. Probably LXC should be most easy, though I never tried it out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.