Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 03-05-2015, 10:33 PM   #1
LQ Newbie
Registered: Mar 2005
Posts: 24

Rep: Reputation: 15
Question making a gateway between LAN1 to LAN2 vv LAN2 to LAN1

I tried many tutorials but it doesn't work for me.

I have two LAN, LAN1 and LAN2, i want them to see each other via ubuntu server 14.04 lts.

Current Settings:

Packet forwarding Enabled
# Uncomment the next line to enable packet forwarding for IPv4

the file /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static

auto eth3
iface eth3 inet static

Now what should i do next, to make me able to access computers in LAN2 from LAN1 or vise-versa?

I don't need masquerading because i want to see who's computer is connected to via IP address.

thank you.

Last edited by ocavid; 03-05-2015 at 10:46 PM.
Old 03-06-2015, 02:37 AM   #2
Registered: Dec 2005
Location: India
Distribution: centos
Posts: 178

Rep: Reputation: 13
add routes to networks
for lan1
route add -net netmask dev eth0
and for lan 2
route add -net netmask dev eth3
try pinging both lans
2 members found this post helpful.
Old 03-06-2015, 03:06 AM   #3
Senior Member
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Let me sum it up and cross check. So you have got two networks:

1 Network 1 --
2 Network 2 --

Things you will require both LANs to communicate.

1. A router, in your case you have got Ubuntu box acting as router. It has got 2 interface, 1 belonging to each network. Right?
2. All the machines of Network 1 should have default route set to the IP that you have set on Network 1 of Ubuntu box.
3. All the machines of Network 2 should have default route set to the IP that you have set on Network 2 of Ubuntu box.
4. IP forwarding should be enabled on Ubuntu box, which you mentioned you already enabled.
5. On Ubuntu box you have to right iptable rules as:

route add -net <NETWORK 1> netmask gw <IP_SET_ON_NETWORK2_INTERFACE_OF_UBUNTU>
route add -net <NETWORK 2> netmask gw <IP_SET_ON_NETWORK1_INTERFACE_OF_UBUNTU>

What zafar_dandoti mentioned in his post is perfectly fine. You can use device instead of IP. I personally prefer IP.
1 members found this post helpful.
Old 03-09-2015, 04:03 AM   #4
LQ Newbie
Registered: Mar 2005
Posts: 24

Original Poster
Rep: Reputation: 15
to zafar_dandoti and T3RM1NVT0R

IT works great!

Thank you!


router, routing

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Making gateway in Ubuntu 01pratap01 Linux - Newbie 1 10-01-2008 07:02 PM
How to route in redhat? (making a gateway) urquanmaster Linux - Networking 2 02-15-2007 07:06 PM
Home->Lan2 using pptp and then Lan2 -> Lan1 pudhiyavan Linux - Networking 2 04-15-2005 12:16 AM
making a default gateway permanent csu19032 Linux - Networking 1 07-01-2004 02:28 PM
Making a gateway Vindane Linux - Networking 4 05-30-2004 06:51 PM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:36 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration