admin管理员组

文章数量:1531514

2024年1月6日发(作者:)

查看linux系统版本,内核,CPU,MEM,位数的相关命令

1.查看版本,内核

[oracle@svr15 ~]$ cat /etc/issue

Red Hat Enterprise Linux AS release 4 (Nahant)

Kernel r on an m

[oracle@svr15 ~]$ cat /proc/version

Linux version (bhcompile@) (gcc

version 3.4.3 20041212 (Red Hat 4)) #1 SMP Wed Jan 5 19:30:39

EST 2005

[oracle@svr15 ~]$ uname -r

2.查看cpu,mem

[oracle@svr15 ~]$ grep "model name" /proc/cpuinfo

model name : Intel(R) Xeon(R) CPU 5130 @ 2.00GHz

model name : Intel(R) Xeon(R) CPU 5130 @ 2.00GHz

model name : Intel(R) Xeon(R) CPU 5130 @ 2.00GHz

model name : Intel(R) Xeon(R) CPU 5130 @ 2.00GHz

[oracle@svr15 ~]$ cat /proc/cpuinfo

processor : 0

vendor_id : GenuineIntel

cpu family : 6

model : 15

model name : Intel(R) Xeon(R) CPU 5130 @ 2.00GHz

stepping : 6

cpu MHz : 1995.006

cache size : 64 KB

physical id : 0

siblings : 2

fdiv_bug : no

hlt_bug : no

f00f_bug : no

coma_bug : no

fpu : yes

fpu_exception : yes

cpuid level : 10

wp : yes

flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge

mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm

pni monitor ds_cpl tm2 xtpr

bogomips : 3956.73

processor : 1

vendor_id : GenuineIntel

cpu family : 6

model : 15

model name : Intel(R) Xeon(R) CPU 5130 @ 2.00GHz

stepping : 6

cpu MHz : 1995.006

cache size : 64 KB

physical id : 0

siblings : 2

fdiv_bug : no

hlt_bug : no

f00f_bug : no

coma_bug : no

fpu : yes

fpu_exception : yes

cpuid level : 10

wp : yes

flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge

mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm

pni monitor ds_cpl tm2 xtpr

bogomips : 3981.31

processor : 2

vendor_id : GenuineIntel

cpu family : 6

model : 15

model name : Intel(R) Xeon(R) CPU 5130 @ 2.00GHz

stepping : 6

cpu MHz : 1995.006

cache size : 64 KB

physical id : 3

siblings : 2

fdiv_bug : no

hlt_bug : no

f00f_bug : no

coma_bug : no

fpu : yes

fpu_exception : yes

cpuid level : 10

wp : yes

flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge

mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm

pni monitor ds_cpl tm2 xtpr

bogomips : 3981.31

processor : 3

vendor_id : GenuineIntel

cpu family : 6

model : 15

model name : Intel(R) Xeon(R) CPU 5130 @ 2.00GHz

stepping : 6

cpu MHz : 1995.006

cache size : 64 KB

physical id : 3

siblings : 2

fdiv_bug : no

hlt_bug : no

f00f_bug : no

coma_bug : no

fpu : yes

fpu_exception : yes

cpuid level : 10

wp : yes

flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge

mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm

pni monitor ds_cpl tm2 xtpr

bogomips : 3981.31

[oracle@svr15 ~]$ grep MemTotal /proc/meminfo

MemTotal: 4147280 kB

[oracle@svr15 ~]$ free

total used free shared buffers cached

Mem: 4147280 4138220 9060 0 106124 3865896

-/+ buffers/cache: 166200 3981080

Swap: 4192924 0 4192924

3.查看操作系统位数

[oracle@svr15 ~]$ ls / #如果有lib64或这个目录,那操作系统就是64位的

bin boot dev etc home initrd lib lost+found media misc mnt

opt proc root sbin selinux srv sys tmp usr var

[oracle@svr15 ~]$ getconf LONG_BIT

32

[oracle@svr15 ~]$ ldd /sbin/mii-tool

.6 => /lib/i686/.6 (0x00b2f000)

/lib/.2 (0x00a49000)

linux配置IP地址

即时生效:

ifconfig eth0 192.168.1.102 netmask 255.255.255.0

启动生效:

vim /etc/sysconfig/network-scripts/ifcfg-eth0

加入

IPADDR=192.168.1.102

NETMASK=255.255.255.0

修改default gateway

即时生效:

route add default gw 192.168.1.1

启动生效:

vim /etc/sysconfig/network-scripts/ifcfg-eth0

加入

GATEWAY=192.168.1.1

最后结果如下:

DEVICE=eth0

BOOTPROTO=static

IPADDR=192.168.1.102

NETMASK=255.255.255.0

GETEWAY=192.168.1.1

ONBOOT=yes

TYPE=Ethernet

注:BOOTPROTO只有在static(静态)模式下才可以使用设置的IP信息

修改dns

vim /etc/

修改后可即时生效,启动同样有效

形式

加入nameserver= ***.***.***.***

最多可有三个,作为上一个失败后的候选

修改host name

即时生效:

hostname fc2

启动生效:

vim /etc/sysconfig/network

形式如下:

NETWORKING=yes

HOSTNAME=

##########################################################

首先,先了解传统的网络配置命令:

1. 使用ifconfig命令配置并查看网络接口情况

示例1: 配置eth0的IP,同时激活设备:

ifconfig eth0 192.168.4.1 netmask 255.255.255.0 up

示例2: 配置eth0别名设备 eth0:1 的IP,并添加路由

ifconfig eth0:1 192.168.4.2

route add –host 192.168.4.2 dev eth0:1

示例3:激活(禁用)设备

ifconfig eth0:1 up(down)

示例4:查看所有(指定)网络接口配置

ifconfig (eth0)

—————————

2. 使用route 命令配置路由表

示例1:添加到主机路由

route add –host 192.168.4.2 dev eth0:1

route add –host 192.168.4.1 gw 192.168.4.250

示例2:添加到网络的路由

route add –net IP netmask MASK eth0

route add –net IP netmask MASK gw IP

route add –net IP/24 eth1

示例3:添加默认网关

route add default gw IP

示例4:删除路由

route del –host 192.168.4.1 dev eth0:1

示例5:查看路由信息

route 或 route -n (-n 表示不解析名字,列出速度会比route 快)

—————————

管理命令

示例1:查看ARP缓存

arp

示例2: 添加

arp –s IP MAC

示例3: 删除

arp –d IP

—————————

4. ip是iproute2软件包里面的一个强大的网络配置工具,它能够替代一些传

统的网络管理工具。例如:ifconfig、route等,

上面的示例完全可以用下面的ip命令实现,而且ip命令可以实现更多的功能.下面介绍一些示例:

4.0 ip命令的语法

ip [OPTIONS] OBJECT [COMMAND [ARGUMENTS]]

4.1 ip link set–改变设备的属性. 缩写:set、s

示例1:up/down 起动/关闭设备。

ip link set dev eth0 up

这个等于传统的

ifconfig eth0 up

ifconfig eth0 down

示例2:改变设备传输队列的长度。

参数:txqueuelen NUMBER或者txqlen NUMBER

ip link set dev eth0 txqueuelen 100

示例3:改变网络设备MTU(最大传输单元)的值。

ip link set dev eth0 mtu 1500

示例4: 修改网络设备的MAC地址。

参数: address LLADDRESS

ip link set dev eth0 address 00:01:4f:00:15:f1

4.2 ip link show–显示设备属性. 缩写:show、list、lst、sh、ls、l

-s选项出现两次或者更多次,ip会输出更为详细的错误信息统计。

示例:

ip -s -s link ls eth0

这个命令等于传统的

ifconfig eth0

—————————

5.1 ip address add–添加一个新的协议地址. 缩写:add、a

示例1:为每个地址设置一个字符串作为标签。为了和Linux-2.0的网络别名兼容,这个字符串必须以设备名开头,接着一个冒号,

ip addr add local 192.168.4.1/28 brd + label eth0:1 dev eth0

等价于

ifconfig eth0:5 192.168.4.1/28

ip addr add local 192.168.4.1/28 dev eth0

示例2: 在以太网接口eth0上增加一个地址192.168.20.0,掩码长度为24位(155.155.155.0),标准广播地址,标签为eth0:Alias:

ip addr add 192.168.4.2/24 brd + dev eth1 label eth1:1

这个命令等于传统的:

ifconfig eth1:1 192.168.4.2/24

5.2 ip address delete–删除一个协议地址. 缩写:delete、del、d

ip addr del 192.168.4.1/24 brd + dev eth0 label eth0:Alias1

5.3 ip address show–显示协议地址. 缩写:show、list、lst、sh、ls、l

ip addr ls eth0

address flush–清除协议地址. 缩写:flush、f

示例1 : 删除属于私网10.0.0.0/8的所有地址:

ip -s -s a f to 10/8

示例2 : 取消所有以太网卡的IP地址

ip -4 addr flush label “eth0″

—————————

6. ip neighbour–neighbour/arp表管理命令

缩写 neighbour、neighbor、neigh、n

命令 add、change、replace、delete、fulsh、show(或者list)

6.1 ip neighbour add — 添加一个新的邻接条目

ip neighbour change–修改一个现有的条目

ip neighbour replace–替换一个已有的条目

缩写:add、a;change、chg;replace、repl

示例1: 在设备eth0上,为地址10.0.0.3添加一个permanent ARP条目:

ip neigh add 10.0.0.3 lladdr 0:0:0:0:0:1 dev eth0 nud perm

示例2:把状态改为reachable

ip neigh chg 10.0.0.3 dev eth0 nud reachable

neighbour delete–删除一个邻接条目

示例1:删除设备eth0上的一个ARP条目10.0.0.3

ip neigh del 10.0.0.3 dev eth0

neighbour show–显示网络邻居的信息. 缩写:show、list、sh、ls

示例1: ip -s n ls 193.233.7.254

193.233.7.254. dev eth0 lladdr 00:00:0c:76:3f:85 ref 5 used 12/13/20 nud

reachable

neighbour flush–清除邻接条目. 缩写:flush、f

示例1: (-s 可以显示详细信息)

ip -s -s n f 193.233.7.254

—————————

7. 路由表管理

7.1.缩写 route、ro、r

7.5.路由表

从Linux-2.2开始,内核把路由归纳到许多路由表中,这些表都进行了编号,编号数字的范围是1到255。另外,

为了方便,还可以在/etc/iproute2/rt_tables中为路由表命名。

默认情况下,所有的路由都会被插入到表main(编号254)中。在进行路由查询时,内核只使用路由表main。

route add — 添加新路由

ip route change — 修改路由

ip route replace — 替换已有的路由

缩写:add、a;change、chg;replace、repl

示例1: 设置到网络10.0.0/24的路由经过网关193.233.7.65

ip route add 10.0.0/24 via 193.233.7.65

示例2: 修改到网络10.0.0/24的直接路由,使其经过设备dummy

ip route chg 10.0.0/24 dev dummy

示例3: 实现链路负载平衡.加入缺省多路径路由,让ppp0和ppp1分担负载(注意:scope值并非必需,它只不过是告诉内核,这个路由要经过网关而不是直连的。实际上,如果你知道远程端点的地址,使用via参数来设置就更好了)。

ip route add default scope global nexthop dev ppp0 nexthop dev ppp1

ip route replace default scope global nexthop dev ppp0 nexthop dev ppp1

示例4: 设置NAT路由。在转发来自192.203.80.144的数据包之前,先进行网络地址转换,把这个地址转换为193.233.7.83

ip route add nat 192.203.80.142 via 193.233.7.83

示例5: 实现数据包级负载平衡,允许把数据包随机从多个路由发出。weight 可以设置权重.

ip route replace default equalize nexthop via 211.139.218.145 dev eth0

weight 1 nexthop via 211.139.218.145 dev eth1 weight 1

route delete– 删除路由

缩写:delete、del、d

示例1:删除上一节命令加入的多路径路由

ip route del default scope global nexthop dev ppp0 nexthop dev ppp1

route show — 列出路由

缩写:show、list、sh、ls、l

示例1: 计算使用gated/bgp协议的路由个数

ip route ls proto gated/bgp |wc

1413 9891 79010

示例2: 计算路由缓存里面的条数,由于被缓存路由的属性可能大于一行,以此需要使用-o选项

ip -o route ls cloned |wc

159 2543 18707

示例3: 列出路由表TABLEID里面的路由。缺省设置是table main。TABLEID或者是一个真正的路由表ID或者是/etc/iproute2/rt_tables文件定义的字符串,

或者是以下的特殊值:

all — 列出所有表的路由;

cache — 列出路由缓存的内容。

ip ro ls 193.233.7.82 tab cache

示例4: 列出某个路由表的内容

ip route ls table fddi153

示例5: 列出默认路由表的内容

ip route ls

这个命令等于传统的: route

route flush — 擦除路由表

示例1: 删除路由表main中的所有网关路由(示例:在路由监控程序挂掉之后):

ip -4 ro flush scope global type unicast

示例2:清除所有被克隆出来的IPv6路由:

ip -6 -s -s ro flush cache

示例3: 在gated程序挂掉之后,清除所有的BGP路由:

ip -s ro f proto gated/bgp

示例4: 清除所有ipv4路由cache

ip route flush cache

*** IPv4 routing cache is flushed.

7.10 ip route get — 获得单个路由 .缩写:get

linux设置DNS方法--[ping: unknown host]

文章分类:操作系统

[问题描述 ]

Linux下如果ping一个域名,出现如下状况:

#ping

ping: unknown host

那是因为系统没有设置DNS的缘故。在此场景下,任何通过域名的操作都会有问题。

[解决办法 ]

1、查看DNS设置

#cat

/etc/

如果能看到 nameserver

说明DNS已经设置,这时要考虑设置的DNS对否。

2、设置DNS

直接编辑

/etc/ 即可

添加正确的DNS 地址.

如下:

nameserver

本文标签: 路由示例地址设置命令