2

based on this sample guide link:
http://ubuntulinux.co.in/blog/ubuntu/nat-configuration-with-iptables-in-ubuntu/

with this code:

iptables –append FORWARD –in-interface eth1 -j ACCEPT

it means that "All PC’s on the private office network should set their “gateway” to be the local private network IP address of the Linux gateway computer."

How can we make our ubuntu server router gateway mode to router mode? In order our private networks is visible from other networks or different subnet.

Scenario:

                             +---+        
                   eth1-*.1.2| S |           +----------+
 *1.1router===switch=========|   |           |          |------PC1
               ||            | / |private net|  switch  |------PC2
               ||            |   |===========|          |------PC3
               ||            | R |eth0-*.0.1 +----------+
               ||            +---+
             *.1.3
              Router
               ||            
               ||
             *.7.1
          other network    

S/R: Server as Router
192.168.x.x
eth1: connection from the internet/other network
eth0: internal/private network
PC1,PC2,PC3: w/ ip add .0.x

13
  • I don't understand the question "How can we make our ubuntu server router gateway mode to router mode?" Could you clarify it by explaining what you're trying to achieve?
    – Oli
    Aug 13, 2013 at 8:20
  • Are you talking about port forwarding?
    – Oli
    Aug 13, 2013 at 8:21
  • Hi @Oli, thanks for you immediate response. What I am trying is to make my private network visible to other network. e.g. my private network had a 192.168.0.0/24 and other network has a 192.168.7.0/24. How can we connect .7.x to .0.x?
    – ckknight
    Aug 13, 2013 at 8:25
  • And there is an Ubuntu server as the gateway to each of these subnets with a common router at the top or is it one Ubuntu server controlling two subnets?
    – Oli
    Aug 13, 2013 at 8:36
  • This might be relevant: askubuntu.com/questions/168033/how-to-set-routes
    – Oli
    Aug 13, 2013 at 8:37

1 Answer 1

1

You'll need to turn on IP forwarding if your static routes are already in place. To do that run sudoedit /etc/sysctl.conf and look for the following segment:

# Uncomment the next line to enable packet forwarding for IPv4
#net.ipv4.ip_forward=1

Do as it says and uncomment the second line so it looks like:

net.ipv4.ip_forward=1

Save and exit. Then run sudo sysctl -p /etc/sysctl.conf to reload the configuration. You might then have to reload the networking stack (sudo restart networking) but after that your 192.168.7.x machines should be able to reach 192.168.0.*

5
  • It is possible that if the OP actually run through the steps of the tutorial and enabled masquerade, it has to be turned off if the hosts from x.x.7.0 network are to be able to reach those in x.x.0.0 network. Aug 13, 2013 at 9:27
  • @moon.musick : do i have to disable or flush the nat masquerade on my iptables?
    – ckknight
    Aug 13, 2013 at 13:41
  • @ckknight I guess that if you have masquerade configured for hosts in x.x.0.0 network and don't have any specific rules allowing direct connection to those hosts from outside (that is, from hosts behind eth1), then yes, you might have to disable masquerading. Try and see, if it does not work, the problem is elsewhere. Aug 13, 2013 at 17:18
  • @moon.musick : yes, it works! thank you so much, guys.
    – ckknight
    Aug 14, 2013 at 0:32
  • The problem found. If we disable the masquerading, it can ping(visible) the hosts (PC1,PC2,PC3) from *.7.x networks but the host can't remote/connect to *.7.x. However, when we enable the the masquerade we can connect to *.7.x but *.7.x can't be ping(invisible). Any idea of what/why is this happened?
    – ckknight
    Aug 14, 2013 at 2:52

You must log in to answer this question.

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