ifconfig命令:查看與配置網絡狀態命令網絡
[root@AmorLei ~]# ifconfig eth0 Link encap:Ethernet HWaddr 00:16:3E:08:C7:DD inet addr:172.17.190.178 Bcast:172.17.191.255 Mask:255.255.240.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:220029 errors:0 dropped:0 overruns:0 frame:0 TX packets:172881 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:86027143 (82.0 MiB) TX bytes:42891195 (40.9 MiB)
[root@AmorLei ~]# ifconfig eth0 192.168.0.100 netmask 255.255.2555.0
# 臨時設置eth0網卡的IP地址與子網掩碼tcp
紅帽專有圖形化工具setup設置IP地址工具
配置完成後須要重啓網絡服務,執行 service network restart 命令。測試
網絡配置信息在以下文件中:spa
1.網卡信息文件.net
[root@AmorLei ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
2.主機名文件3d
[root@AmorLei ~]# vi /etc/sysconfig/network
3.DNS配置文件rest
[root@AmorLei ~]# vi /etc/resolv.conf
[root@AmorLei ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 ONBOOT=yes BOOTPROTO=static IPADDR=172.17.190.178 NETMASK=255.255.240.0
文件中的信息設置了以下內容:code
DEVICE=eth0 : 網卡設備名server
BOOTPROTO=none : 是否自動獲取IP(none、static、dhcp)
HWADDR=00:0c:29:17:c4:09 : MAC地址
NM_CONTROLLED=yes : 是否能夠由Network Manager圖形管理工具託管
ONBOOT=yes : 是否隨網絡服務啓動,eth0生效(配置完IP,沒有生效,手工改成"yes")
TYPE=Ethernet : 類型爲以太網
UUID="44b76c8a-b59f-44d5-83fa-7f98fda86b3d" : 惟一識別碼
IPADDR=192.168.0.252 : IP地址
NETMASK=255.255.255.0 : 子網掩碼
GATEWAY=192.168.0.1 : 網關
DNS1=202.106.0.20 : DNS
IPV6INIT=no : IPv6沒有啓用
USERCTL=no : 不容許非root用戶控制網卡
[root@AmorLei ~]# vi /etc/sysconfig/network NETWORKING=yes HOSTNAME=AmorLei NETWORKING_IPV6=no PEERNTP=no GATEWAY=172.17.191.253 # 須要重啓計算機生效
[root@AmorLei ~]# hostname [主機名] # 查看與臨時設置主機名命令
[root@AmorLei ~]# vi /etc/resolv.conf nameserver 100.100.2.138 nameserver 100.100.2.136 options timeout:2 attempts:3 rotate single-request-reopen
[root@AmorLei ~]# setup
# 修改並配置IP地址
[root@AmorLei ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 把 "ONBOOT=no" 改成 "ONBOOT=yes" [root@AmorLei ~]# service network restart # 重啓網絡服務
1.刪除MAC地址行
[root@AmorLei ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
2.刪除網卡和MAC地址綁定文件
[root@AmorLei ~]# rm -rf /etc/udev/rules.d/70-persistent-net.rules
3.重啓系統
[root@AmorLei ~]# shutdown -r now
ifconfig命令:查看與配置網絡狀態命令
ifdown 網卡設備名
# 禁用該網卡設備
ifup 網卡設備名
# 啓用該網卡設備
netstat 選項
選項:
· ESTABLISHED狀態表明鏈接已經存在
統計遠程鏈接的用戶數量:
netstat -an | grep ESTABLISHED | wc -l
netstat -rn
[root@AmorLei ~]# netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 172.17.176.0 0.0.0.0 255.255.240.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0 0.0.0.0 172.17.191.253 0.0.0.0 UG 0 0 0 eth0
route -n # 查看路由列表(能夠看到網關) route add default gw 192.168.1.1 # 臨時設定網關
nslookup [主機名或IP]
# 進行域名與IP地址解析
# nslookup 命令用來查詢域名對應的IP
nslookup www.bomm.xin
[root@AmorLei ~]# nslookup > server Default server: 202.106.0.20 Address: 202.106.0.20#53 > exit
ping [選項] ip或域名 # 探測指定IP或域名的網絡情況
選項:
telnet [域名或IP] [端口] # 遠程管理與端口探測命令 telnet 192.168.0.252 80
traceroute [選項] IP或域名
# 路由跟蹤命令
選項:
wget http://soft.vpser.net/lnmp/lnmp1.1-full.tar.gz # 下載命令
tcpdump -i eth0 -nnX port 21
選項: