Operating System - Linux
1753850 Members
7527 Online
108807 Solutions
New Discussion юеВ

"ifconfig down" keeping the link state

 
SOLVED
Go to solution
Jdamian
Respected Contributor

"ifconfig down" keeping the link state

Hi guys

I have written down a bash script in RHEL to find out the switch name and port to which a ethernet interface is plugged. I'm interested even in the unconfigured interfaces, i.e., plugged with NO IP address assigned.

The tcpdump tool is used BUT it does not work when the interface is DOWN ("ifconfig -a" shows it but "ifconfig" doesn't)

The obviuos solution focuses on using the ifconfig command to set the interface UP and set back DOWN later.

The command "ifconfig down" denies any *software* access to the interface (fine!) BUT shuts down the link, i.e., "ethtool" reports no link detected -- I do not want this, I wanto the set back to its previous state.

Is there any way to set DOWN the interface without removing the physical link?

I come from the HP-UX world, where the ifconfig actions "plumb" and "unplumb" would be required in this case... but Linux ifconfig does not offer those actions.

Thanx in advance

P.D: does anyone know the difference of the UP and RUNNING keywords in the ifconfig output?
3 REPLIES 3
Wilfred Chau_1
Respected Contributor

Re: "ifconfig down" keeping the link state

there should be startup/shutdown scripts called ifup and ifdown under /etc/sysconfig/network-scripts.

to restart the interface of eth0, you could do
ifdown eth0 followed by ifup eth0

or you can use the ip command, e.g.
ip link set eth0 down
then
ip link set eth0 up
Jdamian
Respected Contributor

Re: "ifconfig down" keeping the link state

No, there is no script under /etc/sysconfig/network-scripts because that interface has no IP address assigned.

The ip tool works as ifconfig:

# ethtool eth4 | grep 'Link detected:'
Link detected: yes
# ip link set eth4 up
# ip link set eth4 down
# ethtool eth4 | grep 'Link detected:'
Link detected: no
Matti_Kurkela
Honored Contributor
Solution

Re: "ifconfig down" keeping the link state

In Linux, you can configure a network interface UP without assigning an IP address to it. This stops the TCP/IP driver stack from using the interface, but the physical link will still be active and low-level access (e.g. tcpdump) is possible.

If the interface is DOWN, you can switch it UP without assigning an IP address with a simple command:

ifconfig up

To remove an already-assigned IP address, you can either reset the IP of the interface to 0.0.0.0:

ifconfig 0.0.0.0

Or you can use "ip addr del
dev ".

The state "UP without an IP address" would be the closest equivalent of HP-UX state "plumbed but not configured".

---------

The UP and RUNNING keywords refer to administrative and operational states, respectively. (In HP-UX, the "administrative state" and "operational state" are viewable with the "lanadmin -g mibstats " command.)

- if the interface has been commanded to activate, the interface will be UP; if not, it will be down (no keyword).
- if the interface is in working order (i.e. any required firmware files are loaded, the interface has been commanded to be UP and it has a valid physical link), the interface will be RUNNING.

The implementation of the RUNNING state varies between different NIC drivers. In general, if a card is UP but not RUNNING, that indicates a problem: the card has been commanded to run, but is unable to do it at the moment.

It is unusual to see an interface that is RUNNING but not UP: that might mean the command to shut down the interface has just been given, but the NIC hardware has not yet completed the shutdown.

MK
MK