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?
4 answers
ip addr add dev eth1 192.168.11.130
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
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
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.