In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to set multiple IP addresses for a single network card on Ubuntu 15.10". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to set multiple IP addresses for a single network card on Ubuntu 15.10.
Sometimes, you may want to use multiple IP addresses on your network card. What will you do in such a situation? Buy a new network card and assign a new IP? No, that's not necessary (at least in small networks). Now we can assign multiple IP addresses to a network card in the Ubuntu system. Want to know how to do it? It's not hard to follow me down.
This method also applies to Debian and its derivative versions.
Temporarily add an IP address
First, let's find the IP address of the network card. In my Ubuntu 15.10 server version, I only used one network card.
Run the following command to find the IP address:
Sudo ip addr
Sample output:
1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6:: 1/128 scope host valid_lft forever preferred_lft forever 2: enp0s3: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 08:00:27:2a:03:4b brd ff:ff:ff:ff:ff:ff inet 192.168.1.103/24 brd 192.168.1.255 scope global enp0s3 valid_lft forever preferred_lft forever inet6 fe80::a00:27ff:fe2a:34e/64 scope link valid_lft forever preferred_lft forever
Or
Sudo ifconfig
Sample output:
Enp0s3 Link encap:Ethernet HWaddr 08:00:27:2a:03:4b inet addr:192.168.1.103 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe2a:34e/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:186 errors:0 dropped:0 overruns:0 frame:0 TX packets:70 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:21872 (21.8KB ) TX bytes:9666 (9.6 KB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: 1Compare 128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:217 errors:0 dropped:0 overruns:0 frame:0 TX packets:217 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:38793 (38.7 KB) TX bytes:38793 (38.7 KB)
As you can see in the output above, my network card name is enp0s3 and its IP address is 192.168.1.103.
Now let's add a new IP address to the network card, for example, 192.168.1.104.
Open your terminal and run the following command to add additional IP.
Sudo ip addr add 192.168.1.104/24 dev enp0s3
Use the command to check if the new IP is enabled:
Sudo ip address show enp0s3
Sample output:
2: enp0s3: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 08:00:27:2a:03:4e brd ff:ff:ff:ff:ff:ff inet 192.168.1.103/24 brd 192.168.1.255 scope global enp0s3 valid_lft forever preferred_lft forever inet 192.168.1.104/24 scope global secondary enp0s3 valid_lft forever preferred_lft forever inet6 fe80::a00:27ff:fe2a:34e/64 scope link valid_lft forever preferred_lft forever
Similarly, you can add as many IP addresses as you want.
Let's ping this IP address and verify it.
Sudo ping 192.168.1.104
Sample output:
PING 192.168.1.104 (192.168.1.104) 56 (84) bytes of data. 64 bytes from 192.168.1.104: icmp_seq=1 ttl=64 time=0.901 ms 64 bytes from 192.168.1.104: icmp_seq=2 ttl=64 time=0.571 ms 64 bytes from 192.168.1.104: icmp_seq=3 ttl=64 time=0.521 ms 64 bytes from 192.168.1.104: icmp_seq=4 ttl=64 time=0.524 ms
Great, it works!
To delete an IP, simply run:
Sudo ip addr del 192.168.1.104/24 dev enp0s3
Check again to see if IP has been deleted.
Sudo ip address show enp0s3
Sample output:
2: enp0s3: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 08:00:27:2a:03:4e brd ff:ff:ff:ff:ff:ff inet 192.168.1.103/24 brd 192.168.1.255 scope global enp0s3 valid_lft forever preferred_lft forever inet6 fe80::a00:27ff:fe2a:34e/64 scope link valid_lft forever preferred_lft forever
As you can see, it's gone!
As you know, these settings will fail after rebooting the system. So how to set it to be effective? It's simple, too.
Add * IP address
The network card configuration file for the Ubuntu system is / etc/network/interfaces.
Let's take a look at the details of the above document.
Sudo cat / etc/network/interfaces
Sample output:
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces (5). Source / etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto enp0s3 iface enp0s3 inet dhcp
As you can see in the output above, the network card has DHCP enabled.
Now, let's assign an additional address, such as 192.168.1.104Universe 24.
Edit / etc/network/interfaces:
Sudo nano / etc/network/interfaces
Add an additional IP address below.
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces (5). Source / etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto enp0s3 iface enp0s3 inet dhcp iface enp0s3 inet static address 192.168.1.104/24
Save and close the file.
Run the following command to make the changes take effect without a restart.
Sudo ifdown enp0s3 & & sudo ifup enp0s3
Sample output:
Killed old client process Internet Systems Consortium DHCP Client 4.3.1 Copyright 2004-2014 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Listening on LPF/enp0s3/08:00:27:2a:03:4e Sending on LPF/enp0s3/08:00:27:2a:03:4e Sending on Socket/fallback DHCPRELEASE on enp0s3 to 192.168.1.1 port 67 (xid=0x225f35) Internet Systems Consortium DHCP Client 4.3.1 Copyright 2004-2014 Internet Systems Consortium. All rights reserved. For info Please visit https://www.isc.org/software/dhcp/ Listening on LPF/enp0s3/08:00:27:2a:03:4e Sending on LPF/enp0s3/08:00:27:2a:03:4e Sending on Socket/fallback DHCPDISCOVER on enp0s3 to 255.255.255.255 port 67 interval 3 (xid=0xdfb94764) DHCPREQUEST of 192.168.1.103 on enp0s3 to 255.255.255.255 port 67 (xid=0x6447b9df) DHCPOFFER of 192.168.1.103 from 192.168.1.1 DHCPACK of 192.168. 1.103 from 192.168.1.1 bound to 192.168.1.103-renewal in 35146 seconds.
Note: if you connect to the server remotely, it is important to put the above two commands on one line, because * commands will disconnect you. In this way, you can keep your ssh session.
Now, let's check if a new IP has been added with the following command:
Sudo ip address show enp0s3
Sample output:
2: enp0s3: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 08:00:27:2a:03:4e brd ff:ff:ff:ff:ff:ff inet 192.168.1.103/24 brd 192.168.1.255 scope global enp0s3 valid_lft forever preferred_lft forever inet 192.168.1.104/24 brd 192.168.1.255 scope global secondary enp0s3 valid_lft forever preferred_lft forever inet6 fe80::a00:27ff:fe2a:34e/64 scope link valid_lft forever preferred_lft forever
Fine! We have added additional IP.
Verify the ping IP address again.
Sudo ping 192.168.1.104
Sample output:
PING 192.168.1.104 (192.168.1.104) 56 (84) bytes of data. 64 bytes from 192.168.1.104: icmp_seq=1 ttl=64 time=0.137 ms 64 bytes from 192.168.1.104: icmp_seq=2 ttl=64 time=0.050 ms 64 bytes from 192.168.1.104: icmp_seq=3 ttl=64 time=0.054 ms 64 bytes from 192.168.1.104: icmp_seq=4 ttl=64 time=0.067 ms
That's great! It works properly. okay.
At this point, I believe you have a deeper understanding of "how to set multiple IP addresses for a single network card on Ubuntu 15.10". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.