Linux: Bouncing Interfaces. ifconfig vs ifup

The differences here are pretty simple.  ‘ifconfig’ allows for actual modification of settings and state of a network adapter.  This will affect the current running configuration.

Setting IP information
ifconfig <interface> <ip addr> netmask <netmask>

Example
ifconfig eth1 10.1.1.200 netmask 255.255.255.0

Display currently up interfaces
# ifconfig
lo        Link encap:Local Loopback
inet addr:127.0.0.1  Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING  MTU:16436  Metric:1
RX packets:162 errors:0 dropped:0 overruns:0 frame:0
TX packets:162 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:85013 (83.0 KiB)  TX bytes:85013 (83.0 KiB)

Bring up an interface
# ifconfig eth1 up

Re-display up interfaces
# ifconfig
eth1      Link encap:Ethernet  HWaddr 00:50:56:A6:32:50
inet addr:10.1.1.200 Bcast:10.1.1.255  Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fea6:3250/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:66 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b)  TX bytes:18956 (18.5 KiB)
Interrupt:185 Base address:0×1480

lo        Link encap:Local Loopback
inet addr:127.0.0.1  Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING  MTU:16436  Metric:1
RX packets:162 errors:0 dropped:0 overruns:0 frame:0
TX packets:162 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:85013 (83.0 KiB)  TX bytes:85013 (83.0 KiB)
‘ifconfig <interface> down’ will take the specified interface offline.

‘ifup’ will bring up the specified interface with the settings stored in ‘/etc/sysconfig/network-scripts/ifup-interfaceName’.  Below is an example of that file.

# cat /etc/sysconfig/network-scripts/ifcfg-eth1
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=static
DHCPCLASS=
HWADDR=00:50:56:A6:6C:9B
IPADDR=10.0.0.155
NETMASK=255.255.255.0
ONBOOT=yes

‘ifdown <interface>’ will take the specified interface offline as well.

Note:  This is from a Centos / RedHat Linux server.  The stored network interface file might not be located under the sysconfig directory on other versions.  So basically, if you “fat finger” configuration information on an interface, you can just ifdown than ifup that interface to reload the previously saved settings.

Advertisement

~ by Kevin Goodman on November 25, 2008.

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 1,031 other followers