PDF download Download Article PDF download Download Article

This wikiHow teaches you how to assign a new IP address to your computer when using Linux. Doing so can prevent connection issues for the item in question.

Assign an IP Address to a Debian, Ubuntu, or Linux Mint Computer

No matter what version of Linux you're running, you'll need to open the Terminal and switch to root. In Debian, Ubuntu, and Linux Mint, use the "ipconfig" command to view your Internet items. Find the item you want to assign an IP address to, then type "sudo ipconfig [name] [ipaddress] netmask 255.255.255.0 up".

Method 1
Method 1 of 2:

Debian, Ubuntu, & Linux Mint

PDF download Download Article
  1. Popular Debian-based Linux distributions include Ubuntu, Mint, and Raspbian versions.
  2. This is the command line app that's the basis of all Linux distributions. Depending on your Linux version, you may have several ways of opening Terminal:
    • Press Ctrl + Alt + T or Ctrl + Alt + F1 (if you're on a Mac, substitute the ⌘ Command key for Ctrl .
    • Click the text box at the top or bottom of the screen if possible.
    • Open the Menu window and find the "Terminal" application, then click on it.
    Advertisement
  3. If you aren't already logged into the "root" user directory, type in su and press Enter , then type in your root user password when prompted and press Enter .
    • A "root" account is the Linux equivalent of an Administrator account on a Windows or Mac computer.
  4. Type in ifconfig and press Enter to do so. You should see a list of item names appear on the left side of the window with their details listed on the right.
    • The top item should be your current router or Ethernet connection. This item's name is "eth0" (Ethernet) or "wifi0" (Wi-Fi) in Linux.
  5. Note the name of the item that you want to change. You'll find the name on the left side of the window.
    • In most cases, this is the "eth0" or "wifi0" item.
  6. Type in sudo ifconfig name ipaddress netmask 255.255.255.0 up —making sure to replace name with your item's name and ipaddress with your preferred IP address—and press Enter .
    • To assign an IP of "192.168.2.100" to your ethernet connection ("eth0"), for example, you'd enter sudo ifconfig eth0 192.168.0.100 netmask 255.255.255.0 here.
  7. Type in route add default gw 192.168.1.1 and press Enter . [1]
  8. Type in echo "nameserver 8.8.8.8" > /etc/resolv.conf and press Enter .
    • If you have a different DNS server address that you would rather use, enter that in the place of 8.8.8.8 .
  9. Enter the ifconfig command again, find your item, and look at the address to the right of the item's name. You should see the IP address that you just assigned.
  10. Advertisement
Method 2
Method 2 of 2:

Red Hat, CentOS, & Fedora

PDF download Download Article
  1. Popular RPM-based Linux distributions include CentOS, Red Hat, and Fedora versions.
  2. This is the command line app that's the basis of all Linux distributions. Depending on your Linux version, you may have several ways of opening Terminal:
    • Press Ctrl + Alt + T or Ctrl + Alt + F1 (if you're on a Mac, substitute the ⌘ Command key for Ctrl .
    • Click the text box at the top or bottom of the screen if possible.
    • Open the Menu window and find the "Terminal" application, then click on it.
  3. If you aren't already logged into the "root" user directory, type in su and press Enter , then type in your root user password when prompted and press Enter .
    • A "root" account is the Linux equivalent of an Administrator account on a Windows or Mac computer.
  4. Type in ip a to view your network connections.
  5. 5
    Find the network connection that you want to change. This will normally be the Ethernet or Wi-Fi connection, which has an IP address currently listed on the right side of the window.
  6. Type in cd /etc/sysconfig/network-scripts and press Enter .
  7. Type in ls and press Enter . You should see your current connection's name in the upper-left side of the network option results.
  8. Type in vi ifcfg- network name and press Enter . Doing so will open the network's properties in your Vi editor.
    • For a network named "eno12345678", for example, you'd enter vi ifcfg-eno12345678 here.
  9. Change the following values:
    • BOOTPROTO - Change dhcp to none
    • Any IPV6 entry - Delete any IPV6 entries entirely by moving the cursor to the I on the left and pressing Del .
    • ONBOOT - Change no to yes
  10. Press Enter to jump down one line from the ONBOOT category, type in IPADDR= and enter the IP address that you want to use, and then press Enter .
    • For example: to use "192.168.2.23" as your IP address, you'd type in IPADDR=192.168.2.23 and press Enter .
  11. 11
    Enter netmask, gateway, and DNS information. To do so: [2]
    • Type in PREFIX=24 and press Enter . You can also enter NETMASK=255.255.255.0 here.
    • Type in GATEWAY=192.168.2.1 and press Enter . Substitute your preferred gateway address if different.
  12. You can use the File menu to do this, or you can type in :wq and press Enter .
  13. Advertisement

Expert Q&A

Ask a Question
      Advertisement

      Video

      Tips

      • Some very specific Linux distributions will require you to go through a different process to assign an IP address. To see your specific distribution's specifications, check online.
      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Name
      Please provide your name and last initial
      Thanks for submitting a tip for review!
      Advertisement

      Warnings

      Advertisement

      About This Article

      Thanks to all authors for creating a page that has been read 743,452 times.

      Reader Success Stories

      • Buddy HaDagi

        Jan 27, 2017

        "I'm not that experienced with Linux. These directions told me step by step how to do what I needed to do. ..." more
      Share your story

      Is this article up to date?

      Advertisement