Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Debian GNU/Linux Reference Guide
Prev Home Next

10.2.1 Low level network configuration – ifconfig and route

Here is an illustration of how to change the IP address of interface eth0 from 192.168.0.3 to 192.168.0.111 and to make eth0 the route to network 10.0.0.0 via 192.168.0.1. We begin by running ifconfig and route without interface arguments in order to display the current status of all network interfaces and routing.

     # ifconfig
     eth0 Link encap:Ethernet  HWaddr 08:00:46:7A:02:B0
          inet addr:192.168.0.3  Bcast:192.168.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:23363 errors:0 dropped:0 overruns:0 frame:0
          TX packets:21798 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:13479541 (12.8 MiB)  TX bytes:20262643 (19.3 MiB)
          Interrupt:9
     
     lo   Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:230172 errors:0 dropped:0 overruns:0 frame:0
          TX packets:230172 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:22685256 (21.6 MiB)  TX bytes:22685256 (21.6 MiB)
     # route
     Kernel IP routing table
     Destination  Gateway      Genmask          Flags Metric Ref Use Iface
     192.168.0.0  *            255.255.0.0      U     0      0     0 eth0
     default      192.168.0.1  255.255.255.255  UG    0      0     0 eth0

First we bring down the interface.

     # ifconfig eth0 inet down
     # ifconfig
     lo   Link encap:Local Loopback
       ... (no more eth0 entry)
     # route
       ... (no more routing table entries)

Then we bring it up with the new IP address and new routing.

     # ifconfig eth0 inet up 192.168.0.111 \
                netmask 255.255.255.0 broadcast 192.168.0.255
     # route add -net 10.0.0.0 netmask 255.0.0.0 gw 192.168.0.1 dev eth0

The result:

     # ifconfig
     eth0 Link encap:Ethernet  HWaddr 08:00:46:7A:02:B0
          inet addr:192.168.0.111  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          ...
     
     lo   Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          ...
     # route
     Kernel IP routing table
     Destination  Gateway      Genmask        Flags Metric Ref Use Iface
     192.168.0.0  *            255.255.255.0  U     0      0     0 eth0
     10.0.0.0     192.168.0.1  255.0.0.0      UG    0      0     0 eth0

For more information see ifconfig(8) and route(8).


Debian GNU/Linux Reference Guide
Prev Home Next

 
 
  Published under the terms of the GNU General Public License Design by Interspire