No relevant resource is found in the selected language.

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Read our privacy policy>

Reminder

To have a better experience, please upgrade your IE browser.

upgrade

FAQ-how to configure ip address and route in linux by command

Publication Date:  2012-09-21 Views:  32 Downloads:  0
Issue Description
how to configure ip address and route in linux by command

Alarm Information
none
Handling Process
SIG system is linux,we can enter graph interface by yast to configure address and route information,but sometimes appearing garble,can not see entirety interface。There introduce a way configure ip address and route by command
 
(1) ifconfig
ifconfig expression is
ifconfig [-a] [-V] [-s]  [[] 
]
[[-]broadcast [
]]
[netmask 
]
[up|down]
there port is network card,address is IP address, broadcast means set broadcast netmask means set netmask
after it,address is netmask IP, up/down means situation of network card
Ifconfig common parameter explain as follows
-a check all of network card situation
-V check ifconfig command version information
-s check stat information
for example
1 the first network card IP address set to 192.168.0.1
ifconfig eth0 192.168.0.1 format ifconfig network equipment name of IP address
2 up/down network card temporarily
down the first network card ifconfig eth0 down
up the first network card ifconfig eth0 up
3 netmask of the first network card set to 255.255.255.0
ifconfig eth0 netmask 255.255.255.0 format ifconfig network equipment netmask

we can set IP address and netmask at once ifconfig eth0 192.168.0.1 netmask 255.255.255.0
4 check first network card situation
ifconfig eth0
if we want to check all of network input ifconfig 
ifconfig 
some important states
UP/DOWN 
number of errors packages in RX means there is a problem in network card incept
number of errors packages in TX means there is a problem in network card sent
(2) route
route command is like this
route [-CFvnee]
route [-v] [-A family] add [-net|-host] target [netmask Nm] [gw Gw]
[metric N] [mod] [reinstate] [[dev] If]
route [-v] [-A family] del [-net|-host] target [gw Gw] [netmask Nm] [metric
N] [[dev] If]
route [-V] [--version] [-h] [--help]
route parameter explain as follows
-v use redundancy output mode
-A family appoint specifical address like "inet" "inet6"
-n use numeric display address as 202.38.75.75 
-e use netstat form output format 
-ee all of output information
-net  target is a segment
-host  target is a host
-F means kernel FIB route list can be changed by -e and -ee 
-C display route cache information in kernel
del delete a route list
add add a route list
Target target is a host or a segment
netmask Nm point to netmask of route list will be added
gw Gw all of ip target packages must pass this gateway metric M  metric field is M
for example
1 add a route list 192.168.0.x should go from interface "eth0"
route add -net 192.168.0.0 netmask 255.255.255.0 dev eth0
2 add a default route
route add 0.0.0.0 gw gateway address
if there is not route suited,use this rule as 3 deletedefault route
route del 0.0.0.0 gw gateway address
4 route output command result as follows
output format are like this
Destination target segment or host
Gateway gateway if not, set *
Genmask netmask
Flags some tag like this
U routeis active
H aim is a host
G use gateway
R reinstate route list produced by dynamic route
D dynamically installed by daemon or redirect
M modified from routing daemon or redirect
! reject route
Metric distance of route
Ref route reference times,do not used in linux kernel
Use check times of route
Iface this route list corresponding export interface
Root Cause
none
Suggestions
none

END