Recipe 3.2 Starting and Stopping the Network Interface

3.2.1 Problem

You want to prevent all remote network connections, incoming and outgoing, on your network interfaces.

3.2.2 Solution

To shut down one network interface, say, eth0:

# ifconfig eth0 down

To bring up one network interface, say, eth0:

# ifconfig eth0 up

To shut down all networking:

# /etc/init.d/network stop


# service network stop                            Red Hat

To bring up all networking:

# /etc/init.d/network start


# service network start           Red Hat

3.2.3 Discussion

Linux provides three levels of abstraction for enabling and disabling your network interfaces (short of unplugging the network cable):


The lowest level, to enable/disable a single network interface. It has other functions as well for configuring an interface in various ways.

/sbin/ifup, /sbin/ifdown

This mid-level pair of scripts operates on a single network interface, bringing it up or down respectively, by invoking ifconfig with appropriate arguments. They also initialize DHCP and handle a few other details. These are rarely invoked directly by users.


A high-level script that operates on all network interfaces, not just one. It runs ifup or ifdown for each interface as needed, and also handles other details: adding routes, creating a lock file to indicate that networking is enabled, and much more. It even toggles the loopback interface, which might be more than you intended, if you just want to block outside traffic.

The scripts ifup, ifdown, and network are pretty short and well worth reading.

3.2.4 See Also

ifconfig(8). usernetctl(8) describes how non-root users may modify parameters of network interfaces using ifup and ifdown, if permitted by the system administrator.

    Chapter 9. Testing and Monitoring