-1

How to Share a connection on Ubuntu Server without NAT

eth0: 192.168.10.156 eth1: 192.168.5.1

I am creating a Cache Server with TPROXY (squid 3.1), but in my network will not use nat as to deliver IP publicos all machines. In all the tutorials that were always observe the configuration of Ubuntu Server always used nat. But need this model:

eth1 (192.168.5.1)> It receives the data and passes it to eth0 (192.168.10.156 Internet)

Squid does its processing and returns the data to the network!

This works with Nat, but do not want to use NAT because the Squid configuration is with TPROXY (Transparent> Ip Client that should appear on the Internet and not Squid "would NAT")

3
  • @AbrahamVanHelpsing This is possible with the right routing tables and forwarding rules. Without NAT, as these are already private RFC1918 addresses. If you make sure both the current NAT device and the PC sharing know about the 192.168.5.0 network, then it's just a IPv4 routing question/answer.
    – gertvdijk
    Jan 24, 2013 at 11:49
  • @gertvdijk, Thanks for noticing that. I'll remove it.
    – saji89
    Jan 24, 2013 at 12:00
  • Your question changed from a routing/networking question to a Squid HTTP proxy question. This is totally different. I think you'll need a bit more basic IPv4 knowledge here. :)
    – gertvdijk
    Jan 24, 2013 at 12:48

2 Answers 2

0

Very general answer

There's very little information given in the question, so I'm assuming the following:

  • Your 192.168.10.0 network is already NATed.
  • You have access on this NAT (router) device.
  • It is capable of adding manual static routes.
  • No firewalls running.
  • Your networks are of size /24 (= subnet mask 255.255.255.0).

Summary

In the steps below it makes all devices aware of the different networks and the routes, all done by regular IPv4 networking and using the Linux routing table. It's needed to enable forwarding on the PC sharing, as it will prevent you from doing this by default (security reasons).

Detailed steps

Then follow these (general) steps:

  1. On the current NAT (router), add a static route:

    192.168.5.0/24 via 192.168.10.156. I don't know what device you have, so I can't provide instructions for doing this. Read the manual of it.

    In case this router is running Ubuntu already, just add the route like this:

    route add -net 192.168.5.0/24 gw 192.168.10.156
    
  2. On the PC you want to share the 192.168.5.0/24 network, make sure it will forward the traffic:

    sysctl -w net.ipv4.ip_forward=1
    

    More info in this answer.

  3. On the client PC make the route to the 192.168.10.0/24 network known by adding it to the route table:

    route add -net 192.168.10.0/24 gw 192.168.5.1
    
3
  • Ok, In this Case: Computer 192.168.5.2 (Connected on Eth1 of ubuntu) don't ping on 192.168.10.1, and (192.168.10.1) is a gateway on may MK whith internet connection. What Client don't ping on 192.168.10.1 ? Jan 24, 2013 at 12:21
  • @TomJunqueira I've tried re-reading your comment several times, and I am confused as to what you're trying to tell/ask in it. Update your question with your attempts and results instead. This site is not a discussion forum, but a Q&A site.
    – gertvdijk
    Jan 24, 2013 at 12:28
  • Post Edited for more details Jan 24, 2013 at 12:40
-1

By principle, what you want to do is a NAT. The action of taking inside network requests to the internet and convert it to a single external IP, for requesting to you internet provider, is a NAT function.

I think what you want is not have to use iptables, and its not nice, due to security reasions. At least a masquerade you need to use.

on /etc/init.d/rc.local add the code:

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 192.168.5.0/24 -o eth0 -j MASQUERADE

this may help you without too much codes.

2
  • OP doesn't want NAT. Apr 26, 2014 at 12:49
  • Louis Matthijssen, take a better look on the answer. What he wants is NAT. He just don't know what is a NAT.
    – novaisjp
    Apr 26, 2014 at 12:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .