LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-11-2017, 05:07 AM   #1
KatrinAlec
Member
 
Registered: Feb 2012
Posts: 113

Rep: Reputation: 13
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.
 
Old 05-12-2017, 03:44 PM   #2
scheidel21
Senior Member
 
Registered: Feb 2003
Location: CT
Distribution: Debian 6+, CentOS 5+
Posts: 1,323

Rep: Reputation: 100Reputation: 100
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
 
Old 05-17-2017, 04:59 AM   #3
KatrinAlec
Member
 
Registered: Feb 2012
Posts: 113

Original Poster
Rep: Reputation: 13
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
(Scope of address) == (scope of variable) kaz2100 Programming 10 01-26-2014 11:54 PM
Double Local Link (Scope:Link) IPv6 address on one interface BernardLinux Linux - Networking 0 09-08-2011 03:43 AM
Removing "Scope:Link" after inet6 addr (CentOS 5.5) BernardLinux Linux - Networking 2 09-04-2011 10:41 PM
[SOLVED] How to make practical use of link scope IPv6 addresses? Dulcinea Linux - Networking 3 06-24-2010 10:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration