Files
notes/Дополнительный_IP_(secondary_ip).md
2022-05-07 22:12:11 +03:00

43 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
### Дополнительный IP на интерфейсе (Secondary IP) Linux
**!дополнительный IP должен быть из другой подсети!**
_Временный IP на интерфейсе до перезагрузки_
**ifconfig**
```
ifconfig [nic]:0 [IP-Address] netmask [mask] up
```
пример
```
ifconfig eth0:0 192.168.2.2 netmask 255.255.255.0 up
```
**ip**
```
ip address add [ip]/[mask-digits] dev [nic]:0
```
пример
```
ip address add 192.168.99.37/24 dev eth0:0
```
_Постоянный дополнительный IP_
для Debain/Ubuntu
```
nano /etc/network/interfaces
```
общий вид
```
auto [NIC]:[n]
iface [NIC]:[n] inet static
address [ip.add.rr.ss]
gateway [gw.ip.ad.rs]
netmask [ne.tm.as.kk]
```
пример
```
auto eth0:1
iface eth0:1 inet static
address 192.168.0.1
gateway 192.168.0.254
netmask 255.255.255.0
```
Можно добавлять несколько блоков с IP адресами. Достаточно указать их номера eth0:0, eth0:1, eth0:2 и т.д.