歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 網絡管理及實驗(route命令和ip命令分別實現)

網絡管理及實驗(route命令和ip命令分別實現)

日期:2017/2/28 14:44:22   编辑:Linux教程

相關閱讀:

route命令詳解與使用實例 http://www.linuxidc.com/Linux/2013-06/86594.htm

CentOS的ifconfig, route以及ip指令的實戰應用 http://www.linuxidc.com/Linux/2013-05/83956.htm

Linux 使用 ip route , ip rule , iptables 配置策略路由 http://www.linuxidc.com/Linux/2013-04/83157.htm

Linux route 的一般用法 http://www.linuxidc.com/Linux/2013-04/83156.htm

Linux 下route命令詳解 http://www.linuxidc.com/Linux/2012-10/72292.htm

一 網絡相關文件

[root@serv01 data]# vim/etc/sysconfig/network-scripts/ifcfg-eth0

[root@serv01 data]# cd/etc/sysconfig/network-scripts/
[root@serv01 network-scripts]# ifconfig

#其他的Linux:不一定是eth0,名字不重要,可以修改
[root@serv01 network-scripts]# ls ifcfg-*
ifcfg-eth0 ifcfg-lo

[root@serv01 network-scripts]# catifcfg-eth0
#設備名
DEVICE="eth0"
#MAC地址,全局唯一。一個局域網裡兩個相同的MAC地址:ARP欺騙
#00:0C:29:廠家ID
#07:DD:3B:廠家定義
HWADDR="00:0C:29:07:DD:3B"
NM_CONTROLLED="yes"
#是否啟動生效
ONBOOT="yes"
#IP地址
IPADDR=192.168.1.11
#子網掩碼:和IP地址一起計算得到網絡號,判斷是否屬於一個網絡段
NETMASK=255.255.255.0
#網關:跨網段傳輸數據
GATEWAY=192.168.1.11
#網關可以配置到該文件下:network。多張網卡都可以走這個網關。全局配置
#主機名 網關配置
[root@serv01 network-scripts]# vim/etc/sysconfig/network

#IP地址和主機名的對應關系
[root@serv01 network-scripts]# ls/etc/hosts
/etc/hosts

[root@larrywen ~]# vim /etc/hosts
[root@serv01 network-scripts]# tail -n2/etc/hosts
192.168.0.29 up01.host.com
192.168.0.185 up02.host.com
#ping域名,也可以ping通
[root@larrywen ~]# ping up01.host.com
[root@larrywen ~]# ping up02.host.com


#DNS配置
[root@serv01 network-scripts]# vim/etc/resolv.conf
[root@serv01 network-scripts]# cat/etc/resolv.conf
nameserver 8.8.8.8

二 基本網絡命令

1.ping命令

#默認一直ping下去,按Ctrl+C結束
[root@larrywen ~]# ping 192.168.1.11

#ping三次
[root@larrywen ~]# ping -c 3 192.168.1.1

#ping三次,並每隔三秒ping一次
[root@serv01 ~]# ping -c 3 -i 3192.168.1.11

#-s:表示可以跟包的大小
[root@serv01 ~]# ping 192.168.1.1 -s 1024
PING 192.168.1.1 (192.168.1.1) 1024(1052)bytes of data.
1032 bytes from 192.168.1.1: icmp_seq=1ttl=64 time=0.130 ms

[root@serv01 ~]# ping --help

#I:指定從哪個設備出去
[root@serv01 ~]# ping -I eth0 192.168.1.11
#
[root@serv01 ~]# ping -I eth1 192.168.1.11

[root@serv02 ~]# ifconfig eth1 172.xxxnetmask=255.255.255.0

2. netstat命令

[root@serv01 ~]# netstat -lanput

#服務的配置文件:端口和服務相對應
[root@serv01 ~]# vim /etc/services

#修改IP地址和子網掩碼
[root@serv01 ~]# ifconfig eth1 172.6.13.11netmask 255.255.255.0

#手動修改MAC地址
[root@serv01 ~]# ifconfig eth1 hw ether00:0C:29:07:DD:3C

[root@serv01 ~]# ifconfig eth0

#手動修改MTU
[root@serv01 ~]# ifconfig eth1 mtu 2000

#修改IP地址和子網掩碼並取別名,臨時有效
[root@serv01 ~]# ifconfig eth1:zk172.6.13.131 netmask 255.255.255.0

[root@serv01 network-scripts]# cpifcfg-eth0 ifcfg-eth1
[root@serv01 network-scripts]# vimifcfg-eth1
[root@serv01 network-scripts]# cpifcfg-eth1 ifcfg-eth1:zk
[root@serv01 network-scripts]# vimifcfg-eth1:zk

#刪除
[root@serv01 ~]# ifconfig eth1:zk del172.6.13.131

接下來請看第2頁精彩內容: http://www.linuxidc.com/Linux/2013-08/89043p2.htm

Copyright © Linux教程網 All Rights Reserved