Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
03-01-2013, 12:17 AM
|
#1
|
LQ Newbie
Registered: Mar 2013
Distribution: Ubuntu, CentOS, Linux Mint, Solaris, Android
Posts: 4
Rep: 
|
[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
or
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;
|
|
|
03-01-2013, 01:01 AM
|
#2
|
Member
Registered: Mar 2007
Location: Bedford, Texas
Posts: 31
Rep:
|
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.
|
|
|
03-01-2013, 11:26 AM
|
#3
|
Member
Registered: Dec 2012
Location: inside the matrix
Distribution: Debian, Xubuntu, Gentoo, Antergos
Posts: 90
Rep:
|
Quote:
Originally Posted by rch1231
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.
|
|
|
03-02-2013, 02:36 AM
|
#4
|
LQ Newbie
Registered: Mar 2013
Distribution: Ubuntu, CentOS, Linux Mint, Solaris, Android
Posts: 4
Original Poster
Rep: 
|
Quote:
Originally Posted by jnihil
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.
|
|
|
03-03-2013, 02:58 AM
|
#5
|
Member
Registered: Dec 2012
Location: inside the matrix
Distribution: Debian, Xubuntu, Gentoo, Antergos
Posts: 90
Rep:
|
Quote:
Originally Posted by CyberNixon
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.
|
|
|
03-04-2013, 10:25 PM
|
#6
|
LQ Newbie
Registered: Mar 2013
Distribution: Ubuntu, CentOS, Linux Mint, Solaris, Android
Posts: 4
Original Poster
Rep: 
|
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.)
|
|
|
All times are GMT -5. The time now is 01:31 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|