Linux change ip address

Q. How do I change ip address in Linux?


A. There are different ways to change IP address in Linux
(a) Command Line tools

(b) Modify configuration files

(c) Use GUI tools

Task: Display current IP address and setting for network interface called eth0

Use ifconfig command:
# ifconfig eth0

eth0      Link encap:Ethernet  HWaddr 00:30:48:5A:BF:46  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::230:48ff:fe5a:bf46/64 Scope:Link
          RX packets:728204 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1097451 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:62774749 (59.8 MiB)  TX bytes:1584343634 (1.4 GiB)

Task: Change IP address

You can change ip address using ifconfig command itself. To set IP address, enter command:
# ifconfig eth0 netmask up
# ifconfig eth0

To make permanent changes to IP address you need to edit configuration file according to your Linux distribution.

Change IP address under RedHat / CentOS / Fedora core Linux

=> Please read – Howto change and setup IP address in Redhat Linux

Change IP address under Debian / Ubuntu Linux

=> Please read – Howto change and setup IP address in Ubuntu / Debian based Linux distros

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

82 comments… add one
  • bheem Jan 22, 2014 @ 18:16


  • jan Apr 28, 2014 @ 7:22

    not working.i got an error that permission denied

  • jan Apr 28, 2014 @ 7:23

    SIOCSIFADDR: Permission denied
    SIOCSIFFLAGS: Permission denied
    SIOCSIFNETMASK: Permission denied
    SIOCSIFBROADCAST: Permission denied
    SIOCSIFFLAGS: Permission denied
    ……………..this is the error what i got

  • Raj Jun 19, 2014 @ 10:30

    Thanks its working and very helpful

  • Nadeem Nov 11, 2014 @ 5:10

    Hi friends
    Can anybody explain and help me find output of the following command

    IP= echo${IP:0:4}

    • Harm Nov 26, 2014 @ 12:51

      IP= will save in a temporary variable named IP.

      echo${IP:0:4} will print that temporary variable starting from character 0, over a length of 4 characters.

      Output: 192.

  • tohid Feb 13, 2015 @ 3:47

    thanks for help :)

  • Morteza May 11, 2015 @ 7:15

    Thanks a lot.

  • mikicat May 27, 2016 @ 17:50

    Thanks, it helped a lot :)

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.