Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Set multiple IP addresses for a single network card on Ubuntu 15.10     - Thunderbird 24.4.2 has been released for use with PPA updates (Linux)

- Ubuntu 14.04 next upgrade to GNOME 3.12 (Linux)

- Machine Learning: Classification of the curse of dimensionality (Programming)

- Ubuntu 12.04 kernel configuration automatically restart and crash dump (Linux)

- C ++ runtime environment built on CentOS 6.6 and Oracle database connection (Database)

- Android will save the picture to see the album and timely (Programming)

- Profile Linux users login shell and login to read (Linux)

- To install and use Docker under linux (Server)

- ogg Oracle to SQL Server 2005 to achieve synchronization (Database)

- grep regular expression (Linux)

- How to install Bugzilla 4.4 on Ubuntu / CentOS 6.x (Linux)

- MySQL use the integer type (Database)

- Redis-- persistence articles (Database)

- Go powerful development server simple example (Server)

- Oracle database, some basic grammatical structures (Database)

- ActionContext and ServletActionContext Summary (Programming)

- Windows Ubuntu dual system a key Ghost, grub rescue prompt solution (Linux)

- Let's Encrypt with semiautomatic into Nginx configuration https (Server)

- Embedded Linux to solve the problem in the time zone (Linux)

- Linux virtual memory and physical memory (Linux)

 
         
  Set multiple IP addresses for a single network card on Ubuntu 15.10
     
  Add Date : 2018-11-21      
         
         
         
  Sometimes you may want to use multiple IP addresses on your network card. In such cases, how would you do it? Buy a new card and assign a new IP? No, there is no need (at least in a small network). Now we can assign multiple IP addresses in the Ubuntu system as a network card. Want to know how to do? Follow me look down, in fact, is not difficult.

This approach also applies to Debian and its derivative versions.

Temporarily add IP addresses

First, let us find the IP address of the network card. In my Ubuntu 15.10 Server Edition, I only use one card.

Run the following command to find the IP address:

sudoip 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

sudoifconfig
Sample output:

enp0s3 Link encap: EthernetHWaddr08: 00: 27: 2a: 03: 4b
inet addr: 192.168.1.103Bcast: 192.168.1.255Mask: 255.255.255.0
inet6 addr: fe80 :: a00: 27ff: fe2a: 34e / 64Scope: Link
UP BROADCAST RUNNING MULTICAST MTU: 1500Metric: 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.8 KB) TX bytes: 9666 (9.6 KB)
lo Link encap: LocalLoopback
inet addr: 127.0.0.1Mask: 255.0.0.0
inet6 addr ::: 1 / 128Scope: Host
UP LOOPBACK RUNNING MTU: 65536Metric: 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 name is card enp0s3, its IP address is 192.168.1.103.

Now let's add a new IP address for the network card, for example, say 192.168.1.104.

Open your terminal and run the following command to add additional IP.

sudoip addr add 192.168.1.104/24 dev enp0s3
Command to check whether the new IP-enabled:

sudoip 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 any number of IP addresses, as long as you want.

Let's look at the IP address of the ping verify.

sudoping192.168.1.104
Sample Output

PING 192.168.1.104 (192.168.1.104) 56 (84) bytes of data.
64 bytes from192.168.1.104: icmp_seq = 1 ttl = 64time = 0.901 ms
64 bytes from192.168.1.104: icmp_seq = 2 ttl = 64time = 0.571 ms
64 bytes from192.168.1.104: icmp_seq = 3 ttl = 64time = 0.521 ms
64 bytes from192.168.1.104: icmp_seq = 4 ttl = 64time = 0.524 ms
Very good, it works!

To delete the IP, only need to run:

sudoip addr del192.168.1.104 / 24 dev enp0s3
Then check whether to delete the IP.

sudoip 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
You can see already gone! !

As you know, these settings will be invalid after restarting the system. So how can we set up a permanent effective? It is also very simple.

 

Add a permanent IP address

NIC configuration file Ubuntu system is the / etc / network / interfaces.

Let's look at the specific content of the above file.

sudocat / etc / network / interfaces
Sample output:

#Thisfile Describes the network interfaces available on your system
#and how to activate them.Formore 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 above output, the card-enabled DHCP.

Now, let's assign an additional address, for example 192.168.1.104/24.

Edit / etc / network / interfaces:

sudonano / etc / network / interfaces
Below to add additional IP addresses.

#Thisfile Describes the network interfaces available on your system
#and how to activate them.Formore 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 for the changes to take effect without rebooting.

sudo ifdown enp0s3 && sudo ifup enp0s3
Sample output:

Killed old client process
InternetSystemsConsortium DHCP Client4.3.1
Copyright2004-2014InternetSystemsConsortium.
All rights reserved.
Forinfo, 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)
InternetSystemsConsortium DHCP Client4.3.1
Copyright2004-2014InternetSystemsConsortium.
All rights reserved.
Forinfo, 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.103from192.168.1.1
DHCPACK of 192.168.1.103from192.168.1.1
bound to 192.168.1.103-- renewal in35146 seconds.
Note: If you connect remotely to the server, the above two commands in a row is very important because the first command will cut off your connection. And this way you can keep your ssh session.

Now, let us use the following command to check whether to add a new IP:

sudoip 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
well! We have added additional IP.

ping IP address again for verification.

sudoping192.168.1.104
Sample output:

PING 192.168.1.104 (192.168.1.104) 56 (84) bytes of data.
64 bytes from192.168.1.104: icmp_seq = 1 ttl = 64time = 0.137 ms
64 bytes from192.168.1.104: icmp_seq = 2 ttl = 64time = 0.050 ms
64 bytes from192.168.1.104: icmp_seq = 3 ttl = 64time = 0.054 ms
64 bytes from192.168.1.104: icmp_seq = 4 ttl = 64time = 0.067 ms
     
         
         
         
  More:      
 
- CentOS 7 install Hadoop-cdh-2.6 (Server)
- Commonly used Linux system camouflage method (Linux)
- Fedora 22 installation and configuration optimization (Linux)
- Replace element and non-replaced elements of learning (Programming)
- Ubuntu How to install screen recording tool Simple Screen Recorder 0.3.1 (Linux)
- Analysis RabbitMQ cluster (Server)
- Merge Sort (Programming)
- CentOS 5.8 (64) Python 2.7.5 installation error resolved (Linux)
- How to configure MongoDB replica set (Database)
- Oracle create a temporary table space group (Database)
- Features and prevention methods elaborate network security grayware (Linux)
- Elasticsearch 2.20 Highlight (Server)
- Ubuntu 12.04 installation DHCP Server (Server)
- JavaScript function closures Quick Start (Programming)
- Oracle archive log full cause abnormal slow database performance (Database)
- Git build a team development environment operating drills (Linux)
- How do I delete a NEEDS RECOVERY rollback state of undo tablespace (Database)
- Using VMware vSphere Client Linux virtual machine installation CentOS6.4 system (Linux)
- How to Check notebook CPU temperature in Ubuntu (Linux)
- Eclipse, Tomcat configuration JNDI connection Oracle data source example (Server)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.