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-01-2013, 12:17 AM   #1
CyberNixon
LQ Newbie
 
Registered: Mar 2013
Distribution: Ubuntu, CentOS, Linux Mint, Solaris, Android
Posts: 4

Rep: Reputation: Disabled
Question [CentOS] Networking woes... "network is unreachable"


Problem
Whenever I try to add the default route while only one NIC is up (with or without the iface specified), I get an error:
Code:
# route add default gw 192.168.1.254 dev eth1
SIOCADDRT: Network is unreachable
I'm able to bring up eth1 via
Code:
# ifup eth1
or
Code:
# ifconfig eth1 up
but ifup throws the error above since it tries to add the network route (equivalent to # route add 192.168.1.0 gw 0.0.0.0 dev eth1); ifconfig doesn't give an error since it just brings up the iface. I've done everything short of a reboot. I've restarted the networking service (# service network restart), unplugged and plugged in the cable, unloaded and loaded the driver. I'm stuck.

I can't really upload/paste the contents of files, but I can transcribe from one machine to another. Please don't ask for really long files :-)

System Info

Two wired NICs on two WANs
eth1:
  • Static IP set via "/etc/sysconfig/network-scripts/ifcfg-eth1": 192.168.1.90
  • GW is a 2Wire RG (for AT&T Uverse): 192.168.1.254
  • mask: 255.255.255.0
eth0:
  • Static IP set via "/etc/sysconfig/network-scripts/ifcfg-eth0": 192.168.10.100
  • GW is a DD-WRT router: 192.168.10.1
  • mask: 255.255.255.0


How I Got Here...
A few days ago, I was trying to figure out why my server couldn't get out to the internet. My last effort was to remove all the routes and re-add them with the script that I wrote that runs at startup. So I did
Code:
# ip route flush table all
like a moron and now it's even more broken! The last time it was working, it was setup to use both NIC's which are connected to different ISP's. I used a guide very similar to this one to set this up.

Last edited by CyberNixon; 03-02-2013 at 02:38 AM. Reason: added note about route added automatically; added note about dual wan setup;
 
Old 03-01-2013, 01:01 AM   #2
rch1231
Member
 
Registered: Mar 2007
Location: Bedford, Texas
Posts: 31

Rep: Reputation: 15
Hello,

What I see as an issue is that you cannot have two gateways. The gateway is the route that packets should take to get to any addresses that in not in your local subnet (either one) and having two gateways is like trying to exit a room from two doors at the same time. Decide which router you want to be the systems primary gateway to the internet and remove the gateway from the other NIC. Once you do that you should be able to get to the internet again.
 
Old 03-01-2013, 11:26 AM   #3
jnihil
Member
 
Registered: Dec 2012
Location: inside the matrix
Distribution: Debian, Xubuntu, Gentoo, Antergos
Posts: 90

Rep: Reputation: 27
Quote:
Originally Posted by rch1231 View Post
What I see as an issue is that you cannot have two gateways.
You can. You simply setup the metric value lower on the prefered default gw and higher on the backup gw. In case you lose the interface to the prefered default gw the system will choose the secondary default gw with the higher metric.
Use the route command to set the metric on each route, like this:

# route add 192.168.1.90 eth1
# route add default gw 192.168.1.254 metric 10

you can do the same for eth0, but chose a different metric.

Last edited by jnihil; 03-01-2013 at 11:34 AM.
 
Old 03-02-2013, 02:36 AM   #4
CyberNixon
LQ Newbie
 
Registered: Mar 2013
Distribution: Ubuntu, CentOS, Linux Mint, Solaris, Android
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jnihil View Post
You can.

# route add 192.168.1.90 eth1
# route add default gw 192.168.1.254 metric 10

you can do the same for eth0, but chose a different metric.
That's pretty much what I did to get it working many months ago, but I used "weight" instead of metric. Same idea... I used a guide not entirely unlike this one.

Can we pretend I only have 1 NIC if I just don't enable the other one? At least while I'm trying to get past this issue... I tried the command above (route add default...) with only eth1 enabled and got the same error: "Network is unreachable".

Last edited by CyberNixon; 03-02-2013 at 02:39 AM.
 
Old 03-03-2013, 02:58 AM   #5
jnihil
Member
 
Registered: Dec 2012
Location: inside the matrix
Distribution: Debian, Xubuntu, Gentoo, Antergos
Posts: 90

Rep: Reputation: 27
Quote:
Originally Posted by CyberNixon View Post
I tried the command above (route add default...) with only eth1 enabled and got the same error: "Network is unreachable".
Did you execute the line before that?
You need to provide us with more details. It's hard trying to guess what is going on.

How about proving us with the commands you typed in, together with the error message.
After the error, also type 'ifconfig -a' and 'netstat -rn' would be useful.
 
Old 03-04-2013, 10:25 PM   #6
CyberNixon
LQ Newbie
 
Registered: Mar 2013
Distribution: Ubuntu, CentOS, Linux Mint, Solaris, Android
Posts: 4

Original Poster
Rep: Reputation: Disabled
I rebooted (after 2+ years ), renamed the files in "/etc/sysconfig/networking-scripts/" so that eth0 is now eth1 and eth1 is now eth0. "eth0" is now the primary one I'm working on.

At this point, this seems to have fixed it. Apparently, at some point, I renamed some parts of the interface files without cycling the interfaces. Once I brought them down and tried to bring them up, it broke. Fixing my bad renaming seems to have fixed that.

Since I've rebooted anyway, I'm going to upgrade from CentOS 5.5 to the lastest.


Thanks for the help!!

(I'll mark as solved as soon as I re-install and confirm I get get online.)
 
  


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
Network configuration failure: "network unreachable" after start-up slackj Linux - Networking 3 10-06-2012 08:09 PM
Problem when restart network "RTNETLINK answers: Network is unreachable" a.albreiki Linux - Networking 2 02-26-2012 11:27 PM
Basic networking problem: "Network is unreachable" phsythax Linux - Networking 2 05-14-2007 09:43 AM
Getting message "connect: Network is unreachable" trying to access the Internet denver1980 Linux - Networking 5 12-29-2004 05:22 PM
tftp - "Destination Unreachable" due to "Port Unreachable" renjithgopal Linux - Security 5 07-24-2003 10:36 AM

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

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