{"id":10780,"date":"2024-12-10T06:38:09","date_gmt":"2024-12-10T06:38:09","guid":{"rendered":"https:\/\/blog.trustedhosting.in\/?p=10780"},"modified":"2026-04-14T13:07:03","modified_gmt":"2026-04-14T13:07:03","slug":"how-to-add-an-ip-address-in-linux","status":"publish","type":"post","link":"https:\/\/www.webystrata.com\/blog\/how-to-add-an-ip-address-in-linux\/","title":{"rendered":"How to Add an IP Address in Linux"},"content":{"rendered":"<h1><\/h1>\n<h1><a href=\"http:\/\/How to Add an IP Address in Linux\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-11501 size-full\" title=\"How to Add an IP Address in Linux\" src=\"https:\/\/www.webystrata.com\/blog\/wp-content\/uploads\/2024\/12\/ChatGPT-Image-Apr-14-2026-06_36_05-PM.png\" alt=\"How to Add an IP Address in Linux\" width=\"1536\" height=\"1024\" srcset=\"https:\/\/www.webystrata.com\/blog\/wp-content\/uploads\/2024\/12\/ChatGPT-Image-Apr-14-2026-06_36_05-PM.png 1536w, https:\/\/www.webystrata.com\/blog\/wp-content\/uploads\/2024\/12\/ChatGPT-Image-Apr-14-2026-06_36_05-PM-300x200.png 300w, https:\/\/www.webystrata.com\/blog\/wp-content\/uploads\/2024\/12\/ChatGPT-Image-Apr-14-2026-06_36_05-PM-1024x683.png 1024w, https:\/\/www.webystrata.com\/blog\/wp-content\/uploads\/2024\/12\/ChatGPT-Image-Apr-14-2026-06_36_05-PM-768x512.png 768w\" sizes=\"auto, (max-width: 1536px) 100vw, 1536px\" \/><\/a><br \/>\nHow to Add an IP Address in Linux<\/h1>\n<div class=\"admonition note\">\n<blockquote><p>You should speak with your account manager to have an IP address assigned to you before adding IPs to your <a href=\"https:\/\/www.trustedhosting.in\/cpanel-hosting.html\" target=\"_blank\" rel=\"noopener\">server<\/a>.<\/p><\/blockquote>\n<\/div>\n<p>The quickest way to add an IP on either CentOS or Ubuntu would be to use the\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">ip<\/span><\/code>\u00a0command as follows:<\/p>\n<div class=\"highlight-bash notranslate\">\n<div class=\"highlight\">\n<blockquote>\n<pre>   ip addr add <span class=\"m\">10<\/span>.10.10.10\/28 brd + dev eth0\r\n<\/pre>\n<\/blockquote>\n<\/div>\n<\/div>\n<p>That example would add an IP of\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">10.10.10.10<\/span><\/code>\u00a0with a netmask of\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">255.255.255.240<\/span><\/code>\u00a0(CIDR\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">\/28<\/span><\/code>) onto the interface\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">eth0<\/span><\/code>.<\/p>\n<p>Although there\u2019s nothing wrong with that command, the IP won\u2019t persist beyond a reboot.<\/p>\n<p>For that, we\u2019ll need to add it the respective network configuration file for our operating system.<\/p>\n<section id=\"centos\">\n<h2>CentOS<\/h2>\n<p>On CentOS 5, 6 and 7, IP addresses are added in files in the following directory:<\/p>\n<div class=\"highlight-console notranslate\">\n<div class=\"highlight\">\n<blockquote>\n<pre><span class=\"go\">   \/etc\/sysconfig\/network-scripts<\/span>\r\n<\/pre>\n<\/blockquote>\n<\/div>\n<\/div>\n<p>Files should be created with the name\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">ifcfg-ethX<\/span><\/code>\u00a0and have the following content:<\/p>\n<div class=\"highlight-console notranslate\">\n<div class=\"highlight\">\n<blockquote>\n<pre><span class=\"go\">   DEVICE=eth0:1<\/span>\r\n<span class=\"go\">   ONBOOT=yes<\/span>\r\n<span class=\"go\">   BOOTPROTO=static<\/span>\r\n<span class=\"go\">   IPADDR=192.168.0.1<\/span>\r\n<span class=\"go\">   NETMASK=255.255.255.0<\/span>\r\n<\/pre>\n<\/blockquote>\n<\/div>\n<\/div>\n<p>Once you\u2019ve added the your configuration file, bring the interface up with the\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">ifup<\/span><\/code>\u00a0command:<\/p>\n<div class=\"highlight-bash notranslate\">\n<div class=\"highlight\">\n<blockquote>\n<pre>ifup eth0:1\r\n<\/pre>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/section>\n<section id=\"ubuntu\">\n<h2>Ubuntu<\/h2>\n<p>On Ubuntu, all the network config is typically stored in one file:\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">\/etc\/network\/interfaces<\/span><\/code><\/p>\n<p>This file should already exist as it\u2019ll have your existing network configuration in place.<\/p>\n<p>Additional IP addresses should be added underneath the existing configuration with the following syntax:<\/p>\n<div class=\"highlight-console notranslate\">\n<div class=\"highlight\">\n<blockquote>\n<pre><span class=\"go\">   auto eth0:1<\/span>\r\n<span class=\"go\">   iface eth0:1 inet static<\/span>\r\n<span class=\"go\">      address 192.168.0.1<\/span>\r\n<span class=\"go\">      netmask 255.255.255.0<\/span>\r\n<\/pre>\n<\/blockquote>\n<\/div>\n<\/div>\n<p>Again, the interface can be brought up with\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">ifup<\/span><\/code>, as so:<\/p>\n<div class=\"highlight-bash notranslate\">\n<div class=\"highlight\">\n<blockquote>\n<pre>   ifup eth0:1<\/pre>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>How to Add an IP Address in Linux You should speak with your account manager to have an IP address&hellip;<\/p>\n","protected":false},"author":1,"featured_media":11501,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-10780","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/posts\/10780","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/comments?post=10780"}],"version-history":[{"count":2,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/posts\/10780\/revisions"}],"predecessor-version":[{"id":11502,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/posts\/10780\/revisions\/11502"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/media\/11501"}],"wp:attachment":[{"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/media?parent=10780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/categories?post=10780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/tags?post=10780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}