LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 05-10-2005, 12:00 AM   #1
2buck56
Member
 
Registered: Oct 2004
Posts: 54

Rep: Reputation: 15
IP tables routing of multiple IP addresses


I have a Fedora Core 2 system that has been installed for about 6 months running IP tables with no problems. The customer just installed a new T1 with multiple IP addresses on it. I changed my IP tables entries to reflect the new IP addresses a couple of weeks ago. Everything has been operating correctly. I have eth0 connected to the T1 and eth1 connected to the internal LAN.
Now the customer has installed a new VOIP telephone system. There are 3 remote buildings. The phone company wants me to use 3 of the spare external IP addresses and route them to 3 different VLANs. This will enable the remote buildings to connect to the main phone system through their swithch. My Fedora system sits between the T1 and everything inside.
What entries do I need to make to IP tables to route 3 of the external addresses to the 3 VLANs? Do I need to add the 3 external addresses as additional IP addresses to eth0?
Presently I have external address 151.xxx.xxx.98 routed to my internal LAN 192.168.1.0/24.

An example of what I am trying to accomplish:
External IP address VLAN to route to
151.xxx.xxx.124 192.168.7.0/24
151.xxx.xxx.125 192.168.8.0/24
151.xxx.xxx.126 192.168.9.0/24
I want all ports open to these VLANs.

Any help would be appreciated.
 
Old 05-10-2005, 01:02 AM   #2
michaelsanford
Member
 
Registered: Feb 2005
Location: Ottawa/Montréal
Distribution: Slackware + Darwin (MacOS X)
Posts: 468

Rep: Reputation: 30
You'll probably want to use the NETMAP target which allows you to map a whole network of addresses onto another network of addresses (via the nat table only).

Technical explanation: "The resulting address will be constructed in the following way: All 'one' bits in the mask are filled in from the new `address'. All bits that are zero in the mask are filled in from the original address."

I've never used it but I assume (one of) the rules would look something like this
Code:
iptables -t nat -A PREROUTING -d 151.xxx.xxx.124 -j NETMAP --to 192.168.7.0/24
Note that the -d should really be a network and not an IP address, so I'm not sure if this will work verbatim, though it seems to work properly:
Code:
root@gateway:~# iptables -t nat -L -v
Chain PREROUTING (policy ACCEPT 34545 packets, 11M bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 NETMAP     all  --  any    any     anywhere             151.1.3.124         192.168.7.0/24
.

I'd also try adding a -d --match iprange 151.xxx.xxx.124-151.xxx.xxx.126 to try to compress it into a single rule.

The neat thing about the NETMAP target is that, IIRC, it doesn't mangle packets so all the host address (151.xxx.xxx.124) should remain intact.

Note: This may be a module or patch that's not commonly available (I compiled nearly every netfilter package into my kernel since it's a gateway...)
 
Old 05-10-2005, 06:43 AM   #3
2buck56
Member
 
Registered: Oct 2004
Posts: 54

Original Poster
Rep: Reputation: 15
Thanks michaelsanford. I will see if the NETMAP module is loaded and give it a try.
 
Old 05-10-2005, 11:20 AM   #4
michaelsanford
Member
 
Registered: Feb 2005
Location: Ottawa/Montréal
Distribution: Slackware + Darwin (MacOS X)
Posts: 468

Rep: Reputation: 30
If it does work let us know
 
Old 05-11-2005, 05:06 PM   #5
2buck56
Member
 
Registered: Oct 2004
Posts: 54

Original Poster
Rep: Reputation: 15
As it turns out, the telephone technician was wrong on what they wanted to do, so I did not get a chance to try this. After further discussions, they just wanted the .7, .8, and .9 networks to be able to see each other and to be able to see the .1 subnet. I did this by adding INPUT and OUTPUT statements for the three new subnets with masks of 255.255.240.0. I also changed the .1 subnet mask to the same thing. They did not want the 3 new subnets to have access to the outside world so I did not add FORWARD statements for them.
Thanks for your help. I did do some research on what you suggested and it looked like it possibly would have worked. But, since I did not try it, I can't say for sure.
 
  


Reply



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
API for using multiple routing tables on Linux Shakesh Linux - Networking 0 08-29-2005 05:45 PM
Routing tables TPB Linux - Networking 3 07-27-2005 09:01 PM
IP Routing Tables collern2 Linux - Security 1 05-23-2005 10:48 AM
routing tables help hadoque Linux - Networking 0 08-28-2004 09:10 AM
routing tables dunkyb Linux - Networking 3 05-25-2003 02:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 03:37 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
Open Source Consulting | Domain Registration