LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   scope link while interface down (https://www.linuxquestions.org/questions/linux-networking-3/scope-link-while-interface-down-4175605690/)

KatrinAlec 05-11-2017 04:07 AM

scope link while interface down
 
Hello,

I'm trying to configure my eth1 interface, so that the routing entry disappears if the interface isn't plugged in.

I can see the state goes from up to down, but the routing entry remains.
Code:

192.168.0.0/24 dev eth1  proto kernel  scope link  src 192.168.0.11
/etc/network/interfaces
Code:

auto eth1
iface eth1 inet static
        address 192.168.0.11
        netmask 255.255.255.0
        broadcast 192.168.0.255

I'd like the routing entry to be removed if it is down because there is no cable in it.
So far I have to use ifdown eth1.

scheidel21 05-12-2017 02:44 PM

Under your network configuration you should add post-down commands

Quote:

auto eth1
iface eth1 inet static
address 192.168.0.11
netmask 255.255.255.0
broadcast 192.168.0.255
post-down route del 192.168.0.0/24
See if that resolves it, it should, although the route should remove itself once the interface is down. Oh actually I think I recall why it's not working, you should allow hot-plugging try this stanza before you try the above one.

Quote:

auto eth1
allow-hotplug eht1
iface eth1 inet static
address 192.168.0.11
netmask 255.255.255.0
broadcast 192.168.0.255

KatrinAlec 05-17-2017 03:59 AM

Thanks for the answer, but neither works.
All the data below shows the state while the cable isn't plugged in.

Code:

root@TDTErsatz:/home/katrin# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
auto eth1
auto eth0

iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
        address 192.168.1.11
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 192.168.1.1
        dns-search Alec.de



iface eth1 inet static
        address 192.168.0.11
        netmask 255.255.255.0
        broadcast 192.168.0.255
        post-down route del 192.168.0.0/24

Code:

root@TDTErsatz:/home/katrin# ip ad show dev eth1
3: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether a0:48:1c:b8:9a:b9 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.11/24 brd 192.168.0.255 scope global eth1
      valid_lft forever preferred_lft forever
    inet6 fe80::a248:1cff:feb8:9ab9/64 scope link
      valid_lft forever preferred_lft forever

Code:

root@TDTErsatz:/home/katrin# ip -s link show dev eth1
3: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
    link/ether a0:48:1c:b8:9a:b9 brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast 
    526164    4638    0      917    0      2055 
    TX: bytes  packets  errors  dropped carrier collsns
    680        8        0      0      0      0

Code:

root@TDTErsatz:/home/katrin# ip route
default via 192.168.1.1 dev eth0
192.168.0.0/24 dev eth1  proto kernel  scope link  src 192.168.0.11
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.11



All times are GMT -5. The time now is 02:46 PM.