Linux学习笔记八[网络基本配置]

admin 发表于 Linux 分类,标签: , , , , ,
0

第九章 网络的基本配置

9.1 配置网卡
[root@centmini ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=none
BROADCAST=192.168.128.255
HWADDR=00:0c:29:3c:23:c0
IPADDR=192.168.128.3
NETMASK=255.255.255.0
NETWORK=192.168.128.0
GATEWAY=192.168.128.2
ONBOOT=yes
TYPE=Ethernet
IP和子网掩码必须设置,其他可省略。
GATEWAY参数也可以在/etc/sysconfig/network 中设置,网卡配置文件优先。

改完后重启网络
[root@centmini ~]# service network restart

DNS解析  /etc/resolv.conf
[root@centmini ~]# cat /etc/resolv.conf
nameserver 192.168.128.2
nameserver 202.102.134.68
9.3 管理路由

显示路由表 route -n

修改路由表

route add [-net | -host ] TARGET gw GATEWAY

[root@centmini ~]# route add -net 192.168.156.0/24 gw 169.254.0.1

察看路由信息:
  route  -n
添加一个静态路由条目
  route  add  -net  netaddr  netmask  gw  ipaddr  dev
设置默认网关
  route  add  default  gw  ipaddr
删除一个路由条目
  route  del  -net netaddr  netmask  gw  ipaddr  dev


发表我的评论

icon_wink.gif icon_neutral.gif icon_mad.gif icon_twisted.gif icon_smile.gif icon_eek.gif icon_sad.gif icon_rolleyes.gif icon_razz.gif icon_redface.gif icon_surprised.gif icon_mrgreen.gif icon_lol.gif icon_idea.gif icon_biggrin.gif icon_evil.gif icon_cry.gif icon_cool.gif icon_arrow.gif icon_confused.gif icon_question.gif icon_exclaim.gif 

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word