Вот то, что находится в моем /etc/network/interfaces
файл:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 172.168.10.252
netmask 255.255.255.0
network 172.168.10.0
broadcast 172.168.10.255
gateway 172.168.10.1
iface eth1 inet static
address 172.168.10.251
netmask 255.255.255.0
network 172.168.10.0
broadcast 172.168.10.255
gateway 172.168.10.10
Я хотел бы использовать eth0 что касается локальной сети и eth1 для Интернета.Спасибо
Для конфигурирования двух интерфейсов говорят, что eth0 и eth1 для использования двух сетей 192.168.0.0/24
и 10.10.0.0/24
инструмент iproute2
могут использоваться для достижения этого.
Шаги:
Редактирование Ваш /etc/network/interfaces
:
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
iface eth0 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1
# The secondary network interface
allow-hotplug eth1
iface eth1 inet static
address 10.10.0.10
netmask 255.255.255.0
Добавляют вторую таблицу маршрутизации путем редактирования '/etc/iproute2/rt_tables:
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
#1 inr.ruhep
1 rt2
Заполняют новую таблицу маршрутизации:
ip route add 10.10.0.0/24 dev eth1 src 10.10.0.10 table rt2
ip route add default via 10.10.0.1 dev eth1 table rt2
# The first command says that the network, 10.10.0.0/24, can be reached through the eth1 interface.
# The second command sets the default gateway.
Добавляют правила маршрутизации:
ip rule add from 10.10.0.10/32 table rt2
ip rule add to 10.10.0.10/32 table rt2
# These rules say that both traffic from the IP address, 10.10.0.10, as well as traffic directed to
# or through this IP address, should use the rt2 routing table
Создание Конфигурации, постоянной путем добавления его к /etc/network/interfaces
:
iface eth1 inet static
address 10.10.0.10
netmask 255.255.255.0
post-up ip route add 10.10.0.0/24 dev eth1 src 10.10.0.10 table rt2
post-up ip route add default via 10.10.0.1 dev eth1 table rt2
post-up ip rule add from 10.10.0.10/32 table rt2
post-up ip rule add to 10.10.0.10/32 table rt2
Источник:
https://www.thomas-krenn.com/en/wiki/Two_Default_Gateways_on_One_System