Ubuntu: SIOCADDRT: File exists Error and Solution

I‘m typing the following command under Ubuntu Linux:

ADVERTISEMENTS

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:

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
1 comment… add one
  • mahdi Oct 6, 2012 @ 18:09

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

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.