LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-05-2015, 11:33 PM   #1
ocavid
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
net.ipv4.ip_forward=1

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
#LAN1
auto eth0
iface eth0 inet static
address 192.168.66.109
netmask 255.255.255.0
network 192.168.66.0
broadcast 192.168.66.255

#LAN2
auto eth3
iface eth3 inet static
address 172.16.4.1
netmask 255.255.255.0
network 172.16.4.0
broadcast 172.16.4.255

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 11:46 PM.
 
Old 03-06-2015, 03:37 AM   #2
zafar_dandoti
Member
 
Registered: Dec 2005
Location: India
Distribution: centos
Posts: 178

Rep: Reputation: 13
add routes to networks
for lan1
Code:
route add -net 172.16.4.0 netmask 255.255.255.0 dev eth0
and for lan 2
Code:
route add -net 192.168.66.0 netmask 255.255.255.0 dev eth3
try pinging both lans
 
2 members found this post helpful.
Old 03-06-2015, 04:06 AM   #3
T3RM1NVT0R
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 -- 192.168.66.0/24
2 Network 2 -- 172.16.4.0/24

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 255.255.255.0 gw <IP_SET_ON_NETWORK2_INTERFACE_OF_UBUNTU>
route add -net <NETWORK 2> netmask 255.255.255.0 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, 05:03 AM   #4
ocavid
LQ Newbie
 
Registered: Mar 2005
Posts: 24

Original Poster
Rep: Reputation: 15
to zafar_dandoti and T3RM1NVT0R

IT works great!

Thank you!
 
  


Reply

Tags
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 08:02 PM
How to route in redhat? (making a gateway) urquanmaster Linux - Networking 2 02-15-2007 08:06 PM
Home->Lan2 using pptp and then Lan2 -> Lan1 pudhiyavan Linux - Networking 2 04-15-2005 01:16 AM
making a default gateway permanent csu19032 Linux - Networking 1 07-01-2004 03:28 PM
Making a gateway Vindane Linux - Networking 4 05-30-2004 07:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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

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