Debian Admin - Your way to Debian World

December 5, 2006

Network Interface Configuration Using ifconfig

by @ 9:20 am. Filed under Network

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

You can configure a network interface from the command line using the basic Linux networking utilities. You configure your network client hosts with the command line by using commands to change your current settings or by editing a number of system files. Two commands, ifconfig and route, are used for network configuration. The netstat command displays information about the network connections.

ifconfig Advantages

ifconfig is used to configure your network interface. You can use it to

Activate or deactivate your NIC or change your NIC’s mode

Change your machine’s IP address, netmask, or broadcast address

Create an IP alias to allow more than one IP address on your NIC

Set a destination address for a point-to-point connection

Using ifconfig with Examples

If you want to find your current ip address you need to enter the following command

ifconfig

Output looks like below

eth0 Link encap:Ethernet HWaddr 00:0F:EA:B2:53:85
inet addr:192.168.2.5 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::20f:eaff:feb2:5385/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:471 errors:0 dropped:0 overruns:0 frame:0
TX packets:695 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:160637 (156.8 KiB) TX bytes:86193 (84.1 KiB)
Interrupt:185 Base address:0×6000

Create new network alias to a network card (NIC)

Syntax

ifconfig [network device]

Example

ifconfig eth0:1 172.30.49.4

Change IP address

ifconfig eth0 172.30.49.13

Change Subnetmask

Syntax

ifconfig netmask [netmask]

Example

ifconfig eth0 netmask 255.255.255.0

Change broadcast address

Syntax

ifconfig broadcast [address]

Example

ifconfig eth0 broadcast 172.30.49.1

Take interface down

Syntax

ifconfig [network device] down

Example

ifconfig eth0 down

Bring interface up

Syntax

ifconfig [network device] ipaddress up

Example

ifconfig eth0 172.30.49.13 up

If you want to know more information about ifconfig check man page

route command

route is used to build the routing tables (in memory) implemented for routing packets as well as displaying the routing information. It is used after ifconfig has initialized the interface. route is normally used to set up static routes to other networks via the gateway or to other hosts.

route Syntax

route [options] [commands] [parameters]

Examples

To display the routing table, use the route command with no options.

route

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.2.0 * 255.255.255.0 U 0 0 0 eth0
default . 0.0.0.0 UG 0 0 0 eth0

Using the -n option to the route command will give the same information, substituting IP addresses for names and asterisks (*), and looks like this

route -n

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0 0 eth0

Add new route

route Syntax

route add default gw ipaddress interface

add a gateway with a specific IP address, you could use the following

route add default gw 172.30.49.1

If you want to know more information about route check man page

Tags: , , , , , , , , ,

You may also be interested in...

Leave a Reply

Subscribe RSS Feed

subscribe to the Debian Admin RSS feed

Internal links:

Sponsors:



Categories:

Support Debian Admin

Amount $:
Website(Optional):

Sponsors:

Archives:

Related Links:


Favourite Sites:

Wordpress Collection
Windows Reference
Ubuntu Geek
DebianHelp
All About Debian Tutorials
Power Electrical
Check Your IP Here
Debian,Ubuntu News
DebCentral
Tuxmachines
Capnkirby
Libervis
Nuxifield
Linux Horizon
Linux Appfinder
Debuntu
GNU/Linux For Everyone
Free Penguin
DebianAdmin is not related to the Debian Project.
This site is copyright © 2006,2007 Debian Admin
All Trademarks are the property of their respective owners.
The contents of this website may not be mirrored or archived without the express written permission of DebianAdmin Site Owner.

DISCLAIMER: All the information, troubleshooting methods, utilities offered in this website is provided AS-IS, without any warranties. Though I strive for perfection, and always test the validity and effectiveness of the troubleshooting content in various systems, I assume no responsibility for your use of these Fixes, Utilities and other troubleshooting advice. The author will not be liable for any special, incidental, consequential or indirect damages due to loss of data or any other reason. All use is completely at your own risk. Changes to the existing content and new additions are made to this website periodically, without notification.
Rodney's Kontera DynamiContext Plugin plugged in.