User Tools

Site Tools


multiple_ip_addresses_on_single_interface

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
multiple_ip_addresses_on_single_interface [2023/11/13 16:50] – [Method 2 the Better Method] walkeradminmultiple_ip_addresses_on_single_interface [2023/11/13 17:26] (current) – [The Better Method] walkeradmin
Line 100: Line 100:
     eno1             UP             192.168.1.223/24 10.32.13.223/24     eno1             UP             192.168.1.223/24 10.32.13.223/24
  
-We can see that the interface has two IP Addresses. The big issue with this method is the Gateway, the first IP Address has the gateway (192.168.1.1) where as the 10.32.13.233 has not gateway. We could change the gateway to accommodate the new additional IP, but I don't believe you can have two gateways. I have not tried to add a second gateway, but I believe that method two would be preferential as this is really a quick method.+We can see that the interface has two IP Addresses. The big issue with this method is the Gateway, the first IP Address has the gateway <color #ed1c24>(192.168.1.1)</color> where as the <color #00a2e8>10.32.13.233</color> has no gateway. We could change the gateway to accommodate the new additional IP, but I don't believe you can have two gateways. I have not tried to add a second gateway, but I believe that method two would be preferential as this is really a quick method.
 \\  \\ 
 \\  \\ 
 ---- ----
 ==== The Better Method ==== ==== The Better Method ====
 +The better method requires using multiple configuration files for a single interface. This method has a couple of advantages, it simplifies adding addresses and allows for multiple gateways to be used.
 +\\ 
 +\\ 
 +In the directory /etc/sysconfig/network-scripts we can see in this example we two interfaces:
 +\\ 
 +<file>
 +-rw-r--r--. 1 root root 255 Nov 13 17:01 ifcfg-eno1
 +-rw-r--r--. 1 root root 232 Nov 13 17:00 ifcfg-eno2
 +</file>
 +
 +<color #ed1c24>ifcfg-eno1</color> is the interface that we want to apply multiple IP Addresses to. Firstly we will copy this interface file and edit each file accordingly. When creating the new interface configuration files we will add a number to the end of each file:
 +\\ 
 +\\ 
 +cp ifcfg-eno1 ifcfg-eno1<color #00a2e8>:0</color>
 +\\ 
 +cp ifcfg-eno1 ifcfg-eno1<color #22b14c>:1</color>
 +\\ 
 +\\ 
 +Now we have three configuration files for interface <color #ed1c24>eno1</color>
 +\\ 
 +\\ 
 +<color #ed1c24>-rw-r--r--. 1 root root 255 Nov 13 17:01 ifcfg-eno1</color>\\ 
 +<color #00a2e8>-rw-r--r--. 1 root root 255 Nov 13 17:04 ifcfg-eno1:0</color> (Alias 1)\\ 
 +<color #22b14c>-rw-r--r--. 1 root root 255 Nov 13 17:06 ifcfg-eno1:1</color> (Alias 2)\\ 
 +\\ 
 +Each one of these interface files will contain the specific IP Address details that are required, but they will all be associated with a single interface. The <color #ed1c24>ifcfg-eno1</color> file is the main interface configuration file and the other two files <color #00a2e8>ifcfg-eno1:0</color> and <color #22b14c>ifcfg-eno1:1</color> only contain the extra information, these are known as aliases.
 +\\ 
 +\\ 
 +**<color #ed1c24>ifcfg-eno1</color>** - In this file we have all of the primary IP Address details:
 +\\ 
 +<file>
 +TYPE=Ethernet
 +PROXY_METHOD=none
 +BROWSER_ONLY=no
 +DEFROUTE=yes
 +IPV4_FAILURE_FATAL=yes
 +NAME=eno1
 +UUID=ca90417f-9df9-4f34-bae5-77aa6531cc00
 +DEVICE=eno1
 +ONBOOT=yes
 +IPADDR=192.168.1.223
 +PREFIX=24
 +GATEWAY=192.168.1.1
 +BOOTPROTO=none
 +IPV6_DISABLED=yes
 +IPV6INIT=no
 +</file>
 +In the next two files, we just enter the additional information:
 +\\ 
 +\\ 
 +**<color #00a2e8>ifcfg-eno1:0</color>**
 +\\ 
 +<file>
 +NAME=eno1
 +UUID=ca90417f-9df9-4f34-bae5-77aa6531cc00
 +DEVICE=eno1:0
 +ONBOOT=yes
 +IPADDR=10.32.13.233
 +PREFIX=24
 +GATEWAY=10.32.13.1
 +PREFIX1=24
 +</file>
 +\\ 
 +**<color #22b14c>ifcfg-eno1:1</color>**
 +<file>
 +NAME=eno1
 +UUID=ca90417f-9df9-4f34-bae5-77aa6531cc00
 +DEVICE=eno1:1
 +ONBOOT=yes
 +IPADDR=137.1.0.100
 +PREFIX=24
 +GATEWAY=137.1.0.1
 +PREFIX1=24
 +</file>
 +Play close attention to the **DEVICE** setting, you must set the name to match the interface file name (so for file <color #22b14c>ifcfg-eno1:1</color> the **DEVICE** name must be <color #22b14c>eno1:1</color>)
 +\\ 
 +\\ 
 +After rebooting the unit, we can now see that there are three IP Addresses on interface ifcfg-eno1.
 +\\ 
 +\\ 
 +Using ip -br -c a to show the IP Addresses:
 +\\ 
 +\\ 
 +eno1   UP   <color #ed1c24>192.168.1.223</color>/24 1<color #00a2e8>0.32.13.223</color>/24 <color #22b14c>130.1.0.233</color>/24
 +\\ 
 +\\ 
 +If we perform an ip route:
 +\\ 
 +<file>
 +default via 192.168.1.1 dev eno1 proto static metric 101
 +10.32.13.0/24 dev eno1 proto kernel scope link src 10.32.13.223 metric 101
 +130.1.0.0/24 dev eno1 proto kernel scope link src 130.1.0.233 metric 101
 +192.168.1.0/24 dev eno1 proto kernel scope link src 192.168.1.223 metric 101
 +11.0.0.0/16 dev eno2 proto kernel scope link src 11.0.223.2 metric 102
 +</file>
 +We can see that the default route is still via **eno1**, and that the other alias IP Addresses are still going via **eno1**.
 +\\ 
 +\\ 
 +
 +
  
  
multiple_ip_addresses_on_single_interface.1699894237.txt.gz · Last modified: 2023/11/13 16:50 by walkeradmin