Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-30-2014, 09:40 PM   #1
LQ Newbie
Registered: Jun 2014
Posts: 1

Rep: Reputation: Disabled
how ip route add in centos

i have server which running Centos and i want to change outgoing ip address.
following is my route and route list

[root@marketport tmp]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface U 0 0 0 venet0 U 0 0 0 venet0 U 1002 0 0 venet0 U 0 0 0 venet0

[root@marketport tmp]# ip route list dev venet0 proto kernel scope link src dev venet0 proto kernel scope link src dev venet0 scope link metric 1002
default dev venet0 scope link

[root@marketport tmp]# ip route add default via dev venet0 src
RTNETLINK answers: Invalid argument

[root@marketport tmp]# ip route add default via
RTNETLINK answers: File exists

anyone please correct me? where is wrong?
thanks you !
Old 07-01-2014, 01:12 AM   #2
Senior Member
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,274

Rep: Reputation: 148Reputation: 148
Try this way..
#route add -net default gw xx.xx.xx.xx dev ethX
Old 07-01-2014, 03:32 PM   #3
LQ Newbie
Registered: Jan 2009
Posts: 20

Rep: Reputation: 3
As far as I can see, you already have a default route. That is why you are getting that error. Your default route is the following:

default dev venet0 scope link

You must change it instead of adding a new one. Try this:

[root@marketport tmp]# ip route change default via <gateway ip> dev venet0 src <your ip>

Last edited by lsalab; 07-01-2014 at 03:34 PM.
Old 07-01-2014, 03:39 PM   #4
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,454

Rep: Reputation: 2052Reputation: 2052Reputation: 2052Reputation: 2052Reputation: 2052Reputation: 2052Reputation: 2052Reputation: 2052Reputation: 2052Reputation: 2052Reputation: 2052
As lsalab said, you already have a default. There can only be one default, if there was more than one then what would "default" even mean? You need to change your current one, not add a new one.


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
How to add a route and keep it vieraci Linux - Networking 2 01-20-2009 09:20 PM
noob: ip route add vs route add jCash Linux - Networking 1 07-19-2007 11:12 AM
How do I add a route??? moonmoth Linux - Networking 3 09-04-2005 06:25 AM
I am not able to add a new route to my route table using route command prashanth s j Linux - Networking 2 09-03-2005 04:34 AM
ip route add ducati620 Linux - Networking 0 06-06-2004 06:11 AM

All times are GMT -5. The time now is 02:59 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration