Advance

How to add a second IP to Debian by terminal commands

How to add a second IP to Debian by terminal commands
4
(4)

Previously you learned about adding second IP on Ubuntu. So let’s review how to add a second IP to Debian by terminal commands. A Debian admin may want their operating system to be active on two networks with different IP ranges. If your server has two physical network cards, you must set the desired IP for both. But if your server has a network card, you need to add virtual network cards to your operating system with the following commands.

How to add a second IP to Debian by terminal commands.

1– Add a second IP temporarily (While you reboot Debian)
2- Add a second IP permanently (if you do not reboot the Debian, the second IP will not be deleted )

How to buy Linux web hosting

Adding a second IP to Debian, like adding a second IP to Ubuntu, requires entering a few simple commands, which we’ll explain below.

Note: The instructions and steps are just applicable to Debian 7 and Debian 8.

 

Add a second IP to Debian (temporary)

1– Enter the Debian terminal environment.
2– Enter the following command to add the second IP.

 ifconfig eth0:1 10.10.10.3 netmask 255.255.0.0 up

In this example, the address 10.10.10.3 is added to Debian as the second IP.

Note: The above IP command will remain in place until the Debian is rebooted, and will be removed after the operating system is rebooted.

Recommended Article: How to Install Nodejs on AlmaLinux 8.4

Add a second IP to Debian (permanent)

1– Enter the Debian terminal environment.

2– Open the file /etc/network/interfaces with an editor.

nano /etc/network/interfaces

3– Enter the following phrase at the end of the opened file.

auto eth0:1    iface eth0:1 inet static    address 10.10.10.5    netmask 255.255.0.0    broadcast 10.10.10.255    network 10.10.10.0

Note: By comparing the above commands to the first IP commands, you will notice that the added option is eth0: 1.

In fact, by entering the phrase eth0: 1, a virtual network card is added to your Debian and uses your main network card to connect to the network.

4– Save the file and exit.

5– Turn on your virtual network card with the following command, when you completed the above steps.

ifup eth0:1

6– Enter the following command, if you need to turn off the added virtual network card.

ifdown eth0:1    

Dear user, we wish this tutorial how to add a second IP to Debian by terminal commands, would be helpful for you, to ask any question or review the conversation of our users about this article, please visit Ask page. Also to improve your knowledge, there are so many useful tutorials ready to on Eldernode training.

How useful was this post?

Click on a star to rate it!

Average rating 4 / 5. Vote count: 4

No votes so far! Be the first to rate this post.

View More Posts
Marilyn Bisson
Content Writer
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

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

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day