Ubuntu: SIOCADDRT: File exists Error and Solution

by on January 3, 2011 · 1 comment· LAST UPDATED January 3, 2011

in

I'm typing the following command under Ubuntu Linux:

route add default gw 192.168.3.2 eth0

But it is giving me out the following error:

SIOCADDRT: File exists

How do I fix this problem?

This error normally displayed when you try to modify or or add a new routing IP address. For example, when you set the same route multiple times you will get this error.

Understanding SIOCADDRT: File exists Message

  1. SIOC: Serial Input Output Controller.
  2. ADD: ADD (addition).
  3. RT: RouTe (routing ip).
  4. File exists - Routing is already configured so delete wrong one and add the new one.

Display Current Routing Table

Open a command-line terminal (select Applications > Accessories > Terminal), and then type the following command to see your current routing table:
$ netstat -r
OR
$ ip route list

Delete Wrong Routing IP Address

Use the following syntax:
$ sudo ip route delete {IP/SUBNET} dev {INTERFACE}
To delete default route 192.168.1.0/24 via eth0, enter:
$ sudo ip route delete 192.168.1.0/24 dev eth0

Add Correct Routing IP

Type the following command:
$ sudo ip route add default via 192.168.3.2
OR
$ sudo route add default gw 192.168.3.2 eth0

Network Configuration File

Edit, /etc/network/interfaces file and setup the correct routing address:

 
auto eth0
iface eth0 inet static
     address 192.168.3.10
     network 192.168.3.0
     netmask 255.255.255.0
     broadcast 192.168.3.255
     ### set router default ip here ###
     gateway 192.168.3.2
 

Say Hello To NetworkManager

Networking on Linux can be painful, especially in comparison to other operating systems. You should never need to use the command line or configuration files to manage your network (unless you want to!); everything should "Just Work" as automatically as possible and never stop you from doing what you want to do. NetworkManager attempts to make networking as invisible as you want it to be. Whether at home, work, or on the move, NetworkManager automatically connects to the last network you told it to connect to. From wired to wireless to mobile broadband to Bluetooth, NetworkManager has you covered.

nm-applet

The nm-applet is the applet which appears in the system tray. One can right-click the applet (the icon of two computers, one below to the other on the left-side) to manage and activate/deactivate your network connections. Clicking on NM-applet will give you the types of connection/hardware you have available. To modify your settings for eth0 or eth1 interface, right click on NM-applet > select Edit Connections. It will brings up the network-connections as follows:

Fig.01: Pain-Free Networking with NetworkManager

Fig.01: Pain-Free Networking with NetworkManager


Click on the Edit button after selecting the Wired tab in Network Connections as shown below:
Fig.02: Editing eth0 network connection

Fig.02: Editing eth0 network connection


Click on the IPv4 Settings tab. Now you can edit the default route and/or set the DNS server and other settings as per your requirements:
Fig.03: Setting up default gateway (routing table)

Fig.03: Setting up default gateway (routing table)

See also:

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 1 comment… read it below or add one }

1 mahdi October 6, 2012 at 6:09 pm

for Deleting Wrong Routing IP Address default gateway
we should use
ip route delete default via IPaddress

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , ,

Previous Faq:

Next Faq: