Device alias in linux

Linux Creating or Adding New Network Alias To a Network Card (NIC)

Q. I would like to create alias for my network card (NIC). How do I setup 2 IP address on One NIC? How do I add alias under Centos / Fedora / Debian / Ubuntu Linux?

A. Linux allows you to add additional network address using alias feature. Please note that all additional network IP address must be in same subnet. For example if your eth0 using 192.168.1.5 IP address then alias must be setup using 192.168.1.0/24 subnet.

ifconfig command line

You can use ifconfig command to configure a network interface and alias. For example:

  • eth0 NIC IP 192.168.1.5
  • eth0:0 first NIC alias: 192.168.1.6

To setup eth0:0 alias type the following command as the root user:
# ifconfig eth0:0 192.168.1.6 up
Verify alias is up and running using following command:
# ifconfig -a
# ping 192.168.1.6
However, if you reboot the system you will lost all your alias. To make it permanent you need to add it network configuration file.

Debian / Ubuntu Linux Instructions

You can configure the additional IP addresses automatically at boot with another iface statement in /etc/network/interfaces:
# vi /etc/network/interfaces
Append text as follows:

Save and close the file. Restart the network:
# /etc/init.d/networking restart

Red Hat / RHEL / CentOS / Fedora Linux Instructions

Copy etc/sysconfig/network-scripts/ifcfg-eth0 file as /etc/sysconfig/network-scripts/ifcfg-eth0:0
# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0
Open file /etc/sysconfig/network-scripts/ifcfg-eth0:0 using vi text editor:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0:0
Find entry that read as follows:

Find entry that read as follows:

Replace it with your actual IP address:

At the end your file should like as follows:

Open file /etc/sysconfig/network-scripts/ifcfg-eth0 and make sure file does not have a GATEWAY= entry:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Find the entry that read as follows:

Remove or comment it out by prefixing # (hash) :

Save the file. Add the GATEWAY= to your /etc/sysconfig/network:

Append or modify GATEWAY entry:

Save the file. Reboot the system or run the following command:

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

Red Hat / CentOS / Fedora Multiple IP address range

You can assign multiple ip address range as follows to eth0:
vi /etc/sysconfig/network-scripts/ifcfg-eth0-range0
Append following code from 202.54.112.120 to 202.54.112.140:

Читайте также:  Mac os как показывать скрытые папки

Save and close the file.

See also:

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

Hello there
I am using Linux enterprise 4 on my Toshipa Laptop but it didn’t recognizing my NIC so I had to ask for the NIC installation file so I get and this is the name of the file install_8_37[1].tar but I dont know what to do after that ,so i need any help to do this but just please make simple and much details as much as you can because I am not quite expert.

This blog explains how to create an aliased interface using a C program.
Link
Might be useful for some of you I guess.

Hello, I am very new to Linux. Currently using Ubuntu and was wondering what the following line means.
“name Ethernet alias LAN card”
Any help on this would be great thanks!

thanks . will try to ad failover ip’s on my ovh box 🙂

Hi sir
If I have several additional IPs, will creating eth0:1, eth0:2 and so on.
work’s ?
thanks 😀

According to the documentation in /usr/share/doc/initscripts-*/sysconfig.txt, the file defining the eth0:0 device on RedHat/RHEL/CentOS/Fedora systems should only contain the information that is different from the parent eth0 device.

I agree with Michael Leahy.

/usr/share/doc/initscripts-*/sysconfig.txt says that the alias interfaces should not duplicate the information contained in the parent device.

/etc/sysconfig/network-scripts/ifcfg- and
/etc/sysconfig/network-scripts/ifcfg-::

The first defines an interface, and the second contains
only the parts of the definition that are different in a
“alias” (or alternative) interface. For example, the
network numbers might be different, but everything else
might be the same, so only the network numbers would be
in the alias file, but all the device information would
be in the base ifcfg file.

Since when does an alias have to be on the same subnet? I use aliases all the time at work to create private “dev” VLANS with servers I SSH to directly (with a simple switch in between).

The ONBOOT parameter is not appropriate for a Virtual IP / IP Alias – you need to use the ONPARENT param instead.

HTH,
Steve Harper

Thanks I just managed to add a new network alias to my server. 🙂 I also followed Steve’s advice about the onboot parameter.

For my centos5 this information was not sufficient. I’ve added a IP alias eth1:1 on a different subnet than eth1 with this ifcfg-eth1:1 file:
GATEWAY=194.xxx.xxx.xxx
TYPE=Ethernet
DEVICE=eth1:1
BOOTPROTO=none
NETMASK=255.255.255.0
IPADDR=194.xxx.xxx.xxx
USERCTL=no
IPV6INIT=no
ONPARENT=yes
PEERDNS=yes

This works fine with a:
service network restart

how many ip alias I can create in rhel 5, till now i have 64 alias of eth0 interface. I’m able to ping till 63th alias but not on 64 why’s that. I have found that in ubuntu we can create till 254 alias from one particular interface card.
any idea all the configuration are perfect and from sitting on the machine i’m able to ping myself on 64 alias.
but not from other machine which is in netwrok

thanks this help to my configure my network

Is there any limit for network aliases?
can i configure i.e. 512 ip addreses to one network card?

Stop taking all the ipv4 addresses for no reason!

Источник

How to Create and Use Alias Command in Linux

Linux users often need to use one command over and over again. Typing or copying the same command again and again reduces your productivity and distracts you from what you are actually doing.

You can save yourself some time by creating aliases for your most used commands. Aliases are like custom shortcuts used to represent a command (or set of commands) executed with or without custom options. Chances are you are already using aliases on your Linux system.

List Currently Defined Aliases in Linux

You can see a list of defined aliases on your profile by simply executing alias command.

Here you can see the default aliases defined for your user in Ubuntu 18.04.

List Aliases in Linux

As you can see, executing.

Is equivalent to running:

You can create an alias with a single character that will be equivalent to a command of your choice.

How to Create Aliases in Linux

Creating aliases is relatively easy and quick process. You can create two types of aliasestemporary ones and permanent. We will review both types.

Creating Temporary Aliases

What you need to do is type the word alias then use the name you wish to use to execute a command followed by «=» sign and quote the command you wish to alias.

The syntax is as follows:

Here is an actual example:

You can then use «wr» shortcut to go to the webroot directory. The problem with that alias is that it will only be available for your current terminal session.

If you open new terminal session, the alias will no longer be available. If you wish to save your aliases across sessions you will need a permanent alias.

Creating Permanent Aliases

To keep aliases between sessions, you can save them in your user’s shell configuration profile file. This can be:

The syntax you should use is practically the same as creating a temporary alias. The only difference comes from the fact that you will be saving it in a file this time. So for example, in bash, you can open .bashrc file with your favorite editor like this:

Find a place in the file, where you want to keep the aliases. For example, you can add them in the end of the file. For organizations purposes you can leave a comment before your aliases something like this:

Save the file. The file will be automatically loaded in your next session. If you want to use the newly defined alias in the current session, issue the following command:

To remove an alias added via the command line can be unaliased using unalias command.

Conclusion

This was a short example on how to create your own alias and execute frequently used commands without having to type each command again and again. Now you can think about the commands you use the most and create shortcuts for them in your shell.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

We are thankful for your never ending support.

Источник

How To Create Device Alias For ASM Disks Using mknod On Linux/Unix

The post provides an example of how to define and associated meaningful device names for Candidate or Member ASM Disks on Linux/Unix using mknod. The example shown below is of a 2 node RAC setup with +ASM1 and +ASM2 instances.

1. We have below mounted on both +ASM1 & +ASM2 instances:

2. On the +ASM1 instance the diskgroups are mapped to the disks as follow:

3. On the +ASM2 instance the diskgroups are mapped to the disks as follow:

4. So the disks mapping on each node is different. This is normal since each node/OS could provide a different disk name (e.g. /dev/rdsk## to access the same physical disk).

5. If you want to have same disks name on all the nodes & ASM instances to access the same physical disks, then you need to create an alias, either mknod devices or symbolic links on the physical disks (e.g. /dev/rdsk##) one each node. For example. assuming you have the next devices on:

Node #1:

Create the alias:

Then you will have the next alias devices:

You will need to set the correct ownership:

Node #2:

Create the alias:

Then you will have the next alias devices:

You will need to set the correct ownership:

6. Then update the asm_diskstring pointing to the new alias devices one both ASM instances:

+ASM1 instance:

+ASM2 instance:

7. Then the next time you restart the ASM instances, they will access the physical disks using the alias located at ‘/asmdisks/asmdisk*’ on each node.

Источник

Читайте также:  Как правильно надо устанавливать windows
Оцените статью