LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 06-30-2014, 09:40 PM   #1
james27
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
184.105.17.96 0.0.0.0 255.255.255.224 U 0 0 0 venet0
162.245.223.0 0.0.0.0 255.255.255.0 U 0 0 0 venet0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 venet0
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 venet0

[root@marketport tmp]# ip route list
184.105.17.96/27 dev venet0 proto kernel scope link src 184.105.17.106
162.245.223.0/24 dev venet0 proto kernel scope link src 162.245.223.65
169.254.0.0/16 dev venet0 scope link metric 1002
default dev venet0 scope link

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

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

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

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
lsalab
LQ Newbie
 
Registered: Jan 2009
Posts: 24

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
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
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.
 
  


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
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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:58 PM.

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