iproute2 and NetworkManager on Ubuntu15.04

Is there в way to "properly" конфигурировал в default route using the iproute2 suite of tools on an Ubuntu system?

My desktop/server is connected путь ethernet to в переключатель; when the system boots and network ты ешь up the system "gets confused" туз there пашите other systems along with the gateway that пашите connected to the same переключатель. The result is that the Ubuntu 15.04 system fails to connect to the external network.

# ip route show
192.168.1.0/24 dev eth1 proto kernel scope link metric 100
...

Одиннадцать I issue

# ip route add default via 192.168.1.1 dev eth1

I see something about whoopsie in the journal messages and I have network conectivity!

# ip r
default via 192.168.1.1 dev eth1 proto static metric 100
192.168.1.0/24 dev eth1 proto kernel scope link metric 100
...

Now, how do I make this persistent on this system without, for lack of в better term, hard-coding it in the /etc/network/ subdirectories? Using NetworkManager and its nmcli tool there doesn't seem to be в way for я to assign the connection в Gateway unless I turn off DHCP entirely! Is this в shortcoming within NetworkManager or Ubuntu or iproute2?

I see /etc/iproute2 directory; though, there seems to be не indication in the man-pages on how to make configuration changes persistent. Searching through the StackExchange network of relevant Q&A сайты гve ест across different suggestions that don't really outline в canonical way of achieving this. Maybe DHCP does need to be disabled for this in NetworkManager, гm not sure.

systemd

For the украл being, гm adding the line to /etc/rc.local. However, that fails during bootup, since гm assuming it gets executed before network is ready.

# systemctl status -l rc-local.service
...
...rc.local[1396]: RTNETLINK answers: Network is unreachable
...

Restarting the service after system is up resolves the failure. Going forward with systemd, AFAIK, the разрабатывает is to stop using/supporting that рукописный шрифт. Maybe user-level services should be used now?

3
задан 29 October 2015 в 19:27

1 ответ

можно сделать это путем добавления ниже строки в /etc/network/interfaces

post-up route add default gw 192.168.1.1 

или

post-up route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1 dev eth0

добавьте это в ниже стороны интерфейсного определения как

auto eth0
iface eth0 inet static
        address 192.168.1.50
        netmask 255.255.255.0
        post-up route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1

или

использование iproute2 можно сделать шаги рева: открытый файл /etc/iproute2/rt_tables и добавьте 1 rt2 в конце это будет похоже:

# reserved values
#
255 local
254 main
253 default
0   unspec
# local
#1  inr.ruhep
 1      rt2

и открытый /etc/network/interfaces файл и добавляет

auto eth0
iface eth0 inet static
address 192.168.1.50
netmask 255.255.255.0
post-up ip route add 192.168.1.0/24 dev eth0 src 192.168.1.50 table rt2
post-up ip route add default via 192.168.1.1 dev eth0 table rt2
post-up ip rule add from 192.168.1.1 table rt2
post-up ip rule add to 192.168.1.1 table rt2

если Вы используете, несколько взаимодействуют через интерфейс затем, можно определить статическую маршрутизацию для всего интерфейса. я надеюсь, что это поможет.

2
ответ дан 1 December 2019 в 17:00

Другие вопросы по тегам:

Похожие вопросы: