LinuxQuestions.org
Help answer threads with 0 replies.
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 10-31-2014, 08:39 AM   #1
jpetro49
LQ Newbie
 
Registered: Oct 2014
Posts: 8

Rep: Reputation: Disabled
CentOS 6.5 router questions


Hello, I am working on a project for college where I am building a router out of a CentOS 6.5 machine. I have 2 NICs. One NIC will be hooked up to a linksys E2000 that is connected to my modem, and the other NIC will be hooked up to a WRT54GL running DDWRT and acting as a switch. THIS IS NOT CURRENTLY HOW IT IS SET UP BUT IT WILL BE

Everything I have done so far has been from what I have either read on similar posts here or other websites.

The E2000 is on the 192.168.1.0/24 network on eth0.
The WRT54 is going to be on the 192.168.2.0/24 network on eth1... that's the plan anyway.

Currently eth1 is hooked up to another PC which will be explained below. This is just until I know that I have the 2 networks talking then I will hook up eth1 to the WRT54 and continue.

I am having issues being able to talk from one subnet to the other. I more so just want to be pointed in the right direction rather than someone telling me word for word what I need to type into the CLI to get this to work.

So far I am just to trying to establish basic connectivity. I have edited my IPTABLES to just allow everything. I know it's not safe, but I want to get basic connectivity to work before I start setting rules and restricting stuff. Plus this is all internal at the moment so I really have nothing to fear at this point.

My /etc/sysconfig/iptables looks like this.

Code:
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -j ACCEPT
-A OUTPUT -j ACCEPT
-A FORWARD -i eth0 -j ACCEPT
-A FORWARD -i eth1 -j ACCEPT
COMMIT
/etc/sysconfig/network-scripts/ifcfg-eth0

Code:
DEVICE=eth0
TYPE=Ethernet
HWADDR=00:40:CA:6E:58:6A
UUID=ef6f090f-273b-42bf-8ec7-acb8c7bc9d04
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=static
IPADDR=192.168.1.201
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
BROADCAST=192.168.1.255
/etc/sysconfig/network-scripts/ifcfg-eth1
Code:
DEVICE=eth1
HWADDR=00:A0:C9:2A:DC:A7
TYPE=Ethernet
UUID=eeb93c55-063d-4666-bb70-17672a87f798
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=static
IPADDR=192.168.2.1
NETMASK=255.255.255.0
BROADCAST=192.168.2.255
I currently have another PC hooked up to eth1 with a static IP of 192.168.2.2 255.255.255.0 and a gateway of 192.168.2.1 with Google's DNS servers. I can't even get that PC to ping the CentOS box or vice versa. I think my problem is I need to set up static routes in /etc/sysconfig/network-scripts/route-eth0 and route-eth1. I have tried many different configurations and I think I am probably just doing something wrong with it. Currently they are.

route-eth0
Code:
[root@Centos network-scripts]# vim route-eth0
192.168.2.0/24 via 192.168.1.201 dev eth0
and route-eth1

Code:
[root@Centos network-scripts]# vim route-eth1
192.168.1.0/24 via 192.168.2.0 eth1
I have ipv4 forwarding enabled in the sysctl.conf file.

Code:
[root@Centos sysconfig]# vim /etc/sysctl.conf
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and
# sysctl.conf(5) for more details.

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

# Controls source route verification
net.ipv4.conf.default.rp_filter = 1
At this point I am lost. I have tried all sorts of different things. Please tell me what I am doing wrong. Thanks in advance.
Attached Thumbnails
Click image for larger version

Name:	centos.PNG
Views:	29
Size:	26.3 KB
ID:	16796  

Last edited by jpetro49; 10-31-2014 at 09:50 AM. Reason: Added image of current setup.
 
Old 10-31-2014, 12:21 PM   #2
jpetro49
LQ Newbie
 
Registered: Oct 2014
Posts: 8

Original Poster
Rep: Reputation: Disabled
UPDATE

All the addresses have 192.168 before them, I am just shortening them to be easier to read.

Ok so I have made some progress. I am now able to ping from the Windows PC (.2.2) to .2.1 AND .1.201. I can ping from .2.1 to .2.2 which is the Windows PC. I still can't get from 2.2 to 1.1 though.

I cannot however ping from .1.201 to .2.2. nor can I ping between the 2 interfaces which I find very confusing.

If I can get from 2.2 to 1.201 then why can't I get from 2.1 to 1.201 and vice versa?

I accomplished this basically by deleting the route-eth0 and -eth1 files.
 
Old 10-31-2014, 03:22 PM   #3
LVsFINEST
Member
 
Registered: Aug 2006
Posts: 99

Rep: Reputation: 21
Code:
[root@Centos network-scripts]# vim route-eth1
192.168.1.0/24 via 192.168.2.0 eth1
Double check route-eth1. The syntax is wrong (missing "dev") + you have the incorrect IP address.

Last edited by LVsFINEST; 10-31-2014 at 03:28 PM.
 
Old 10-31-2014, 08:49 PM   #4
jpetro49
LQ Newbie
 
Registered: Oct 2014
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by LVsFINEST View Post
Code:
[root@Centos network-scripts]# vim route-eth1
192.168.1.0/24 via 192.168.2.0 eth1
Double check route-eth1. The syntax is wrong (missing "dev") + you have the incorrect IP address.
Thanks. Yes that was just one of the many different attempts I have made so far with the route-eth0 and 1 files. I have since changed it to no avail.

Code:
[root@Centos network-scripts]# cat route-eth0
192.168.2.0/24 via 192.168.1.201 dev eth0

[root@Centos network-scripts]# cat route-eth1
192.168.1.0/24 via 192.168.2.1 dev eth1

[root@Centos network-scripts]# service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down interface eth1:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Determining if ip address 192.168.1.201 is already in use for device eth0...
                                                           [  OK  ]
Bringing up interface eth1:  Determining if ip address 192.168.2.1 is already in use for device eth1...
RTNETLINK answers: File exists
                                                           [  OK  ]
With the above setup I can't get anything to talk. Once I comment the lines out in the route files and restart network service I can get from 2.2 > 2.1 and 1.201, but I can only get from 2-1 > 2.2 the other way. This is starting to hurt my head...lol
 
Old 11-01-2014, 10:24 AM   #5
jpetro49
LQ Newbie
 
Registered: Oct 2014
Posts: 8

Original Poster
Rep: Reputation: Disabled
UPDATE

I feel stupid. I needed to NAT it. I added the following line.

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

I also had to add a route to the E2000 to allow .1.0/24 to see .2.0/24.

I can now ping back and forth between my laptop on the .1 and my PC on the .2!

Do I need to do anything for NAT in terms of PREROUTING? It seems to be working fine right now. I have internet access from the Windows PC 2.2.

I still don't understand why I can't ping between the 2 NICs on the CentOS box. I guess it isn't a big deal since it's currently working, but I always like to know the WHY behind things.

My next steps are going to be to get DHCP running on this machine and start to enforce some more restrictive IPTABLES rules. I'm sure I will run into problems on those. Then I will hook eth1 up to the WRT54 and see if I can get it to switch properly.
 
  


Reply


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
centos as router problem amr.es Linux - Networking 4 02-22-2014 07:09 AM
Configuring CentOS as a router DK907 Linux - Networking 4 05-16-2013 01:54 PM
questions on router hgdcjq Linux - Networking 9 08-24-2012 06:20 PM
[SOLVED] old router behind new router, config questions linuxbird Linux - Networking 2 10-31-2010 08:26 AM
router - few questions dunkyb Linux - Networking 12 06-10-2003 03:56 AM

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

All times are GMT -5. The time now is 10:47 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