zoukankan      html  css  js  c++  java
  • day4-网卡

    查看网络接口的命令为ifconfig,常用的选项为“-a”,可以列出所有网络接口的信息。

    利用arp -an命令可以查看本机的ARP缓存表,需注意的是ARP缓存表是临时生成的,在查看前需要ping一下其它主机,生成一条ARP缓存记录。

    查看路由表命令为route –n。其中有标记“U”为直连路由,“UG”为静态路由。

    可以利用netstat –anptu命令,查看本机当前监听的都有哪些端口。可以利用“|”交由grep命令进行筛选。

    ifconfig 命令

    Interface Configure

    ifconfig 网络接口

    ifconfig -a 列出所有接口 包括禁用的

    ethX:以太网连接

    lo:本地回环接口

    stiX:ipv6地址网卡接口

    fddX:光纤网卡

    PPPX:ADSL宽带或VPN连接

    查看本机路由表

    route 

    -n 显示数字地址

    [root@localhost ~]# route -n

    Kernel IP routing table

    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

    192.168.100.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0

    169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0

    [root@localhost ~]# route 

    Kernel IP routing table

    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

    192.168.100.0   *               255.255.255.0   U     0      0        0 eth0

    link-local      *               255.255.0.0     U     1002   0        0 eth0

    arp

    -a:列出所有条目

    -n:显示数字地址

    [root@localhost ~]# arp -an

    ? (192.168.100.1) at 00:50:56:c0:00:01 [ether] on eth0

    netstat命令 Network Statistics

    -a显示所有活动连接

    -n以数字形式显示

    -p显示进程信息

    -t、-u查看TCP连接、UDP连接

    -r显示路由表

    [root@localhost ~]# netstat -anptu|grep ESTABLISHED

    tcp        0      0 192.168.100.100:22          192.168.100.1:13593         ESTABLISHED 2504/sshd           

    tcp        0     52 192.168.100.100:22          192.168.100.1:10317         ESTABLISHED 2207/sshd     

    查看本机路由表

    [root@localhost ~]# netstat -rn

    Kernel IP routing table

    Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface

    192.168.100.0   0.0.0.0         255.255.255.0   U         0 0          0 eth0

    169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0

    查看指定端口是否开启

    [root@localhost ~]# netstat -ln|grep :22

    tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      

    tcp        0      0 :::22                       :::*                        LISTEN  

    查看指定服务监听的端口

    [root@localhost ~]# netstat -tulnp|grep sshd

    tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1945/sshd           

    tcp        0      0 127.0.0.1:6010              0.0.0.0:*                   LISTEN      2207/sshd           

    tcp        0      0 127.0.0.1:6011              0.0.0.0:*                   LISTEN      2508/sshd           

    tcp        0      0 :::22                       :::*                        LISTEN      1945/sshd           

    tcp        0      0 ::1:6010                    :::*                        LISTEN      2207/sshd           

    tcp        0      0 ::1:6011                    :::*                        LISTEN      2508/sshd        

    ping命令 测试网络连接

    -c 包个数

    -s 包大小

    ctrl+c中止测试

    追踪路由过程

    traceroute

    mtr IP地址

    测试DNS解析

    host 目标主机

    nslookup 目标主机

    临时配置

    wKioL1eq6NKStApzAABfsb950WE604.png

    设置路由记录

    wKiom1eq6TCj8uL1AABii-e13TE746.png

    网卡配置文件

    系统服务 /etc/init.d/network

    [root@localhost ~]# ll /etc/sysconfig/network-scripts/ifcfg-eth0 

    -rw-r--r--. 1 root root 182 8月   9 17:17 /etc/sysconfig/network-scripts/ifcfg-eth0

    [root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

    DEVICE=eth0    设备名

    HWADDR=00:0C:29:60:34:B9    MAC地址

    TYPE=Ethernet    网络类型

    UUID=f162cfbc-8a6d-4ee7-9450-2f12d6c42249    UUID

    ONBOOT=yes    随network服务启用

    NM_CONTROLLED=yes    

    BOOTPROTO=none    或者dhcp、static

    IPADDR=192.168.100.100    静态ip地址

    NETMASK=255.255.255.0    子网掩码

    DNS1=114.114.114.114    DNS

    改完后,重启网卡服务

    6版本可以关闭NetworkManager服务

    主机名配置文件

    [root@localhost ~]# vim /etc/sysconfig/network

    NETWORKING=yes

    HOSTNAME=localhost.localdomain

    主机映射文件

    [root@localhost ~]# vim /etc/hosts

    127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

    ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

    dns配置文件

    [root@localhost ~]# ll /etc/resolv.conf 

    -rw-r--r--. 1 root root 228 8月   9 17:18 /etc/resolv.conf

    静态路由配置文件

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

    修改udev规则,重新命名网卡名称

    [root@localhost ~]# cat /etc/udev/rules.d/70-persistent-net.rules 

    # This file was automatically generated by the /lib/udev/write_net_rules

    # program, run by the persistent-net-generator.rules rules file.

    #

    # You can modify it, as long as you keep each rule on a single

    # line, and change only the value of the NAME= key.

    # PCI device 0x8086:0x100f (e1000)

    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:60:34:b9", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

    modprobe -rv e1000 卸载网卡驱动

    modprobe -v e1000 挂载网卡驱动

    scp是非常方便的远程复制工具:

    上传:scp [-r] 用户名@服务器:路径 本地路径

    下载:scp [-r] 本地路径 用户名@服务器:路径

    上传下载时要注意,权限问题。

    上传:本地要有读取和执行权限,对远程主机要有读取、执行、写入。

    下载:本地要有读取、执行、写入,对远程主机要有读取和执行权限。

    [root@localhost ~]# scp /root/anaconda-ks.cfg root@192.168.100.100:/mnt/

    The authenticity of host '192.168.100.100 (192.168.100.100)' can't be established.

    RSA key fingerprint is 1d:4d:3e:cd:0c:7e:78:7d:29:9d:15:4f:a1:fd:b1:c1.

    Are you sure you want to continue connecting (yes/no)? yes

    Warning: Permanently added '192.168.100.100' (RSA) to the list of known hosts.

    root@192.168.100.100's password: 

    anaconda-ks.cfg                                         100% 1284     1.3KB/s   00:00   

    [root@localhost ~]# ll /mnt/anaconda-ks.cfg 

    -rw-------. 1 root root 1284 8月  11 22:24 /mnt/anaconda-ks.cfg

  • 相关阅读:
    C++笔记(2018/2/6)
    2017级面向对象程序设计寒假作业1
    谁是你的潜在朋友
    A1095 Cars on Campus (30)(30 分)
    A1083 List Grades (25)(25 分)
    A1075 PAT Judge (25)(25 分)
    A1012 The Best Rank (25)(25 分)
    1009 说反话 (20)(20 分)
    A1055 The World's Richest(25 分)
    A1025 PAT Ranking (25)(25 分)
  • 原文地址:https://www.cnblogs.com/fina/p/5781815.html
Copyright © 2011-2022 走看看