How do I assign an IP address to a specific network adapter in Linux/Unix?

How do I assign an IP address to a specific network adapter in Linux/Unix?

 0
Author: aleksandr barakin, 2010-10-25

4 answers

ip addr add dev eth1 192.168.11.130
 2
Author: rtfm, 2015-07-08 11:24:19

To configure network interfaces, use the ip or ifconfig utilities. Below is the information about the utility ifconfig.

Display information on all interfaces:

Sudo ifconfig -a

Интерфейсы начинающиеся на eth* - проводные.
Интерфейсы начинающиеся на wlan* - беспроводные.

Output information on the specified wlan0 interface:

Sudo ifconfig wlan0

Enable the wlan0 network interface

Sudo ifconfig wlan0 up

Disable the wlan0 network interface

Sudo ifconfig wlan0 down

Setting the IP address for the wlan0 interface

Sudo ifconfig wlan0 10.0.5.2

Setting the subnet mask for the wlan0 interface

Sudo ifconfig wlan0 netmask 255.255.255.0

 2
Author: Ishutinov Dmitry, 2017-09-11 07:12:36

To do this, open the terminal, and run the following command (it is assumed that you need to configure the eth1 adapter to the ip address 192.168.11.130)

sudo ifconfig eth1 192.168.11.130
 1
Author: Nicolas Chabanovsky, 2010-10-25 14:29:37

Or sudo nano /etc/network/interfaces

And there:

allow-hotplug eth0
iface eth0 inet static
address 172.22.7.4 #IP-Адресс
netmask 255.255.0.0 #Маска подсети
network 172.22.0.0 #Сеть (начало диапазона сети)
broadcast 172.22.255.255 #Сеть (коне диапазона сети)
gateway 172.22.0.1 #Шлюз
dns-nameservers 172.22.0.1 #Днс сервер
dns-search stavr.net.ua #Сетевой домен если есть

The last two points are not desirable to write.

And if you need an alias, then:

iface eth0:1 inet static

And then there is a description as in the usual interface.

 1
Author: StarCOM, 2017-09-11 07:31:40