LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 04-21-2015, 05:16 AM   #1
bxxst
LQ Newbie
 
Registered: Jul 2013
Posts: 4

Rep: Reputation: Disabled
Configuring Centos as router with virtual interface


Hi everybody

I'm newbie in unix os so, plz, have patience...

I have this issue:

I have a physical machine with only one phisical network card and i have to connect 3 subnet
I have create 3 virtual interface

eth0:1 Link encap:Ethernet HWaddr 00:01:80:68:5A:14
inet addr:85.18.22.33 Bcast:85.18.22.63 Mask:255.255.255.224
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:20 Memory:fdfc0000-fdfe0000

eth0:2 Link encap:Ethernet HWaddr 00:01:80:68:5A:14
inet addr:217.153.107.1 Bcast:217.153.107.31 Mask:255.255.255.224
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:20 Memory:fdfc0000-fdfe0000

eth0:3 Link encap:Ethernet HWaddr 00:01:80:68:5A:14
inet addr:192.168.141.4 Bcast:192.168.141.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:20 Memory:fdfc0000-fdfe0000

connected on layer 2 switch where the network that have access on internet is eth0:3

I have enabled kernel routing in sysclt.cnf

# Controls IP packet forwarding
net.ipv4.ip_forward = 1

and set

iptables -t nat -A POSTROUTING -o eth0:3 -j MASQUERADE

but when i try to connect from a machine on network on eth0:1 to eth0:2 , router put me on real Internet althought routin is as follow

217.153.107.0 * 255.255.255.224 U 0 0 0 eth0
85.18.22.32 * 255.255.255.224 U 0 0 0 eth0
192.168.141.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 1002 0 0 eth0
default 192.168.141.1 0.0.0.0 UG 0 0 0 eth0

At the end, i would like that machine in network on eth0:1 will no nated on network on eth0:2 but machine on network on eth0:1 and eth0:2 must be nated on eth0:3 because they have to access to real ineternet

Any ideas ?

Thanks for all

PS OS is a CentOS 6
 
Old 04-22-2015, 02:00 PM   #2
swampthing001
Member
 
Registered: May 2005
Distribution: LFS, CentOS, Slack, Ubuntu
Posts: 112

Rep: Reputation: 8
Have you looked into pfsense? I know this can be done with pfsense.
 
Old 04-23-2015, 02:16 AM   #3
bxxst
LQ Newbie
 
Registered: Jul 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
I find a solution so easy so stupid

So, I set a MASQUERADE on eth0 in nat table but for each server in the "false" internet subnet that need to connect the othe "false" internet subnet , i set a SNAT as his original ip

To be more clear

[root@rooter ~]# iptables -t nat -L -n
Chain PREROUTING (policy ACCEPT)
target prot opt source destination

Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
SNAT all -- 85.18.22.36 217.153.107.4 to:85.18.22.36
MASQUERADE all -- 0.0.0.0/0 0.0.0.0/0

Chain OUTPUT (policy ACCEPT)
target prot opt source destination


I hope this can help
 
  


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
Configuring CentOS as a router DK907 Linux - Networking 4 05-16-2013 01:54 PM
Error configuring Virtual Machine on CentOS 6 ashutosh0084 Linux - Virtualization and Cloud 3 10-08-2012 09:46 AM
[SOLVED] CentOS 5.5 Virtual Interface Ip problems ax8l Linux - Networking 4 06-17-2011 07:27 AM
Creating a virtual interface to get more ephemeral ports (CentOS 5) MediocreGopher Linux - Networking 1 01-25-2011 09:47 PM
Configuring web interface with client router (Ubuntu) Narvius Linux - Networking 0 10-19-2009 02:06 PM

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

All times are GMT -5. The time now is 10:05 AM.

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