10.11 Linux网络相关 10.12 firewalld和netfilter 10.13 netfilter5表5链介绍 10.14 iptables语法

可莉
• 阅读 445

10.11 Linux网络相关

ifconfig命令

  • 查看网卡IP

如果系统没有该命令可以使用yum安装:

[root@cham2 ~]#yum install -y net-tools

查看网卡IP还可以使用命令:ip addr,这个显示有点乱!

  • ifconfig -a

显示所有网卡信息(包括down掉的或者没有IP地址的网卡)

启动/关闭网卡

应用环境:更改单个指定网卡配置后需要重启才能生效,为了避免关闭或重启所有网卡可以对单个网卡执行该命令。

[root@cham2 ~]# ifdown ens33 && ifup ens33
成功断开设备 'ens33'。
成功激活的连接(D-Bus 激活路径:/org/freedesktop/NetworkManager/ActiveConnection/6)

注: 如果网卡正在使用中,不要单独使用ifdown命令!!!解决办法: “# ifdown ens33 && ifup ens33”,使两个命令一起执行!

为虚拟机添加网卡

[root@cham2 ~]# cd /etc/sysconfig/network-scripts/
[root@cham2 network-scripts]# ls
ifcfg-ens33  ifdown-ippp    ifdown-sit       ifup-bnep  ifup-plip    ifup-Team          network-functions-ipv6
ifcfg-lo     ifdown-ipv6    ifdown-Team      ifup-eth   ifup-plusb   ifup-TeamPort
ifdown       ifdown-isdn    ifdown-TeamPort  ifup-ib    ifup-post    ifup-tunnel
ifdown-bnep  ifdown-post    ifdown-tunnel    ifup-ippp  ifup-ppp     ifup-wireless
ifdown-eth   ifdown-ppp     ifup             ifup-ipv6  ifup-routes  init.ipv6-global
ifdown-ib    ifdown-routes  ifup-aliases     ifup-isdn  ifup-sit     network-functions
[root@cham2 network-scripts]# cp ifcfg-ens33 ifcfg-ens37
[root@cham2 network-scripts]# vi !$
vi ifcfg-ens33\:0

TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33:0
UUID=ad4d8fdd-1916-47fb-a43e-ee8685229fc4
DEVICE=ens33:0
ONBOOT=yes
IPADDR=192.168.230.150
NETMASK=255.255.255.0
~                                                                                                               
~                          
说明:更改NAME、DEVICE、IPADDR,系统已经设定网关可DNS,所以在此可以删除GATEWAY和DNS,也可以保留,但是,如果要保留该选项则必须保持其与系统网卡配置一致!


[root@cham2 network-scripts]# ifdown ens33 && ifup ens33
成功断开设备 'ens33'。
成功激活的连接(D-Bus 激活路径:/org/freedesktop/NetworkManager/ActiveConnection/7)
[root@cham2 network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.230.135  netmask 255.255.255.0  broadcast 192.168.230.255
        inet6 fe80::6f15:52d3:ebeb:e193  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:b6:9f:e3  txqueuelen 1000  (Ethernet)
        RX packets 100550  bytes 46379597 (44.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 112074  bytes 40382050 (38.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens33:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.230.150  netmask 255.255.255.0  broadcast 192.168.230.255
        ether 00:0c:29:b6:9f:e3  txqueuelen 1000  (Ethernet)

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 128  bytes 10604 (10.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 128  bytes 10604 (10.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@cham2 network-scripts]# 

检测虚拟网啊IP是否通畅

在Windows系统cmd下ping该IP即可!

 查看网卡是否连接

  • 方法1:mii-tool [网卡名]

  • 方法2:ethtool [网卡名]

    [root@cham2 ~]# mii-tool ens33 ens33: negotiated 1000baseT-FD flow-control, link ok 查看:link ok说明网卡连接OK!

    [root@cham2 ~]# ethtool ens33 Settings for ens33: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Supported pause frame use: No Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Advertised pause frame use: No Advertised auto-negotiation: Yes Speed: 1000Mb/s Duplex: Full Port: Twisted Pair PHYAD: 0 Transceiver: internal Auto-negotiation: on MDI-X: off (auto) Supports Wake-on: d Wake-on: d Current message level: 0x00000007 (7) drv probe link Link detected: yes 查看:Link detected: yes说明网卡连接OK!

主机名

  • 更改主机名&主机名配置文件

    更改: [root@cham2 ~]# hostnamectl set-hostname cham002

    查看主机名: [root@cham2 ~]# hostname cham002 更改后的主机名要在系统重启之后才会显示!

    主机名的配置文件: [root@cham002 ~]# cat /etc/hostname cham002

    变成主机名,也可以重新登录 [root@cham2 ~]# bash [root@cham002 ~]#

DNS配置

  • DNS配置文件:/etc/resolv.conf

    [root@cham002 ~]# cat /etc/resolv.conf

    Generated by NetworkManager

    nameserver 119.29.29.29

    [root@cham002 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33 添加DNS2=8.8.8.8 [root@cham002 ~]# ifdown ens33 && ifup ens33 成功断开设备 'ens33'。 成功激活的连接(D-Bus 激活路径:/org/freedesktop/NetworkManager/ActiveConnection/8) [root@cham002 ~]# cat /etc/resolv.conf

    Generated by NetworkManager

    nameserver 119.29.29.29 nameserver 8.8.8.8

注: 更改网卡配置即可更改DNS配置文件,更改后需要重启网卡(ifdown/ifup)后生效,也可编辑‘/etc/resolv.conf’临时更改DNS配置,该办法在重启网卡后会被网卡配置文件中的DNS覆盖!

本地域名配置文件文件:/etc/hosts

[root@cham002 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@cham002 ~]# vi /etc/hosts
增加一行192.168.230.150    www.qq123.com

[root@cham002 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.230.150    www.qq123.com

[root@cham002 ~]# !ping
ping www.qq123.com
PING www.qq123.com (192.168.230.150) 56(84) bytes of data.
64 bytes from www.qq123.com (192.168.230.150): icmp_seq=1 ttl=64 time=0.042 ms
64 bytes from www.qq123.com (192.168.230.150): icmp_seq=2 ttl=64 time=0.034 ms
64 bytes from www.qq123.com (192.168.230.150): icmp_seq=3 ttl=64 time=0.033 ms
64 bytes from www.qq123.com (192.168.230.150): icmp_seq=4 ttl=64 time=0.089 ms
^C
--- www.qq123.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3000ms
rtt min/avg/max/mdev = 0.033/0.049/0.089/0.024 ms

说明: 使用vi命令可在该配置文件下可以自定义IP所对应的域名(一个IP对应多个域名或一个域名对应多个IP,用空格隔开,当一个域名对应多个IP时,以配置文件中靠后面的配置为准),但是该域名配置只在本机生效!

10.12 firewalld和netfilter

SELinux防火墙

临时关闭SELinux防火墙:

[root@cham002 ~]# setenforce 0
setenforce: SELinux is disabled

永久关闭SELinux防火墙:

编辑配置文件‘/etc/selinux/config’

10.11 Linux网络相关 10.12 firewalld和netfilter 10.13 netfilter5表5链介绍 10.14 iptables语法

将SELINUX=enforcing改为disabled保存,重启系统即可!

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

查看SELinux防火墙状态

10.11 Linux网络相关 10.12 firewalld和netfilter 10.13 netfilter5表5链介绍 10.14 iptables语法 10.11 Linux网络相关 10.12 firewalld和netfilter 10.13 netfilter5表5链介绍 10.14 iptables语法

[root@cham002 ~]# getenforce
Disabled

netfilter(Firewalld)

>Centos7中默认将原来(centos5/6)的防火墙netfileter升级为了firewalld。iptables是它们实现防火墙功能的工具。

为了方便学习,暂时停用firewalld,开启centos6/5的防火墙机制netfilter。

  • 停用firewalld

    1、关闭firewalld(禁止开机启动) [root@cham002 ~]# systemctl disable firewalld Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

    2、停止firewalld服务 [root@cham002 ~]# systemctl stop firewalld

  • 开启netfilter

    开启前先安装iptables工具包: [root@cham002 ~]# yum install -y iptables-services 已加载插件:fastestmirror

    开启iptables服务: [root@cham002 ~]# systemctl enable iptables Created symlink from /etc/systemd/system/basic.target.wants/iptables.service to /usr/lib/systemd/system/iptables.service. [root@cham002 ~]# systemctl start iptables

说明: 安装完成后默认开启iptables服务。

  • 查看iptables规则:iptables -nvL

    [root@cham002 ~]# iptables -nvL Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination
    29 1940 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0
    0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
    0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination
    0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT 17 packets, 1508 bytes) pkts bytes target prot opt in out source destination

10.13 netfilter 5表及链的介绍

表名

  • filter:包过滤,用于防火墙规则。
  • nat:地址转换,用于网关路由器。
  • mangle:用于给数据包打标记,然后根据标记去操作那些表。(不常用)
  • 还有两个不常用的表:raw和security,不多讲述。

规则链名

  • filter的三种链:

    • INPUT链:作用于输入本机的数据包。
    • OUTPUT链:作用于本机输出的数据包。
    • FORWARD链:作用于与本机无关的包。
  • nat的三种链:

    • PREROUTING链:作用是在包刚刚到达防火墙时改变它的目的地址,如果需要的话。
    • OUTPUT链:改变本地产生的包的目的地址。
    • POSTROUTING链:在包离开防火墙之前改变其源地址。

nat表应用(了解内容)

环境:
假设有三台机器(A,B,C),A机器上有一块网卡连接公网IP1;B机器上有两块网卡b1、b2,。b1、b2分别连接公网和私网IP2,、IP3;C机器上有一块网卡连接私网IP4。很明显此时A&B,B&C之间都分别能互通,但是A和C之间是不能直接连通的,只能借助B做媒介才能连通。那么如何设置才能使得A和C之间互通呢?

10.14 iptables语法

>iptables命令是Linux上常用的防火墙软件,是netfilter项目的一部分。可以直接配置,也可以通过许多前端和图形界面配置。

语法: iptables [options] [参数]
Options:
-n:不针对IP反解析主机名
-v:显示更详细的信息
-t:指定表(iptables命令默认作用于filter表)
-L:显示信息
-F:清空所有规则
-A/D:=add/delete,添加/删除一条规则
-I:插入一条规则
-p:指定协议,可以是tcp,udp或icmp
--sport:跟-p一起使用,指定源端口
--dport:跟-p一起使用,指定目标端口
-s:指定源IP(可以是一个IP段)
-d:指定目的IP(可以是一个IP段)
-j:后面跟动作(ACCEPT表示允许包;DROP表示丢掉包;REJECT表示拒绝包)
-i:指定网卡
-Z:把包以及流量计数器清零
-P:=pre,预设策略

service iptables restart重启服务

  • 查看规则

    [root@cham002 ~]# iptables -nvL
    Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
     pkts bytes target     prot opt in     out     source               destination         
       28  1848 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
        0     0 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           
        0     0 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
        0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22
        0     0 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited
    
    Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
     pkts bytes target     prot opt in     out     source               destination         
        0     0 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited
    
    Chain OUTPUT (policy ACCEPT 15 packets, 1428 bytes)
     pkts bytes target     prot opt in     out     source               destination         
    
    
    [root@cham002 ~]# iptables -t nat -nvL
    Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
     pkts bytes target     prot opt in     out     source               destination         
    
    Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
     pkts bytes target     prot opt in     out     source               destination         
    
    Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
     pkts bytes target     prot opt in     out     source               destination         
    
    Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
     pkts bytes target     prot opt in     out     source               destination      
    

     iptables规则配置文件:/etc/sysconfig/iptables

  • 清空规则

    [root@cham002 ~]# iptables -F
    

    注: 该命令不会清除配置文件内的规则!当更改规则后需要执行命令‘service iptables save’将其保存到配置文件。

  • 增加一条规则(-A/I)

  •   [root@cham002 ~]# iptables -A INPUT -s 192.168.188.1 -p tcp --sport 1234 -d 192.168.188.128 --dport 80 -jDROP
        
      [root@cham002 ~]# iptables -nvL
      Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
       pkts bytes target     prot opt in     out     source               destination         
        304 20360 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
          0     0 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           
          0     0 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
          0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22
          0     0 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited
          0     0 DROP       tcp  --  *      *       192.168.188.1        192.168.188.128      tcp spt:1234 dpt:80
      
      Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
       pkts bytes target     prot opt in     out     source               destination         
          0     0 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited
      
      Chain OUTPUT (policy ACCEPT 23 packets, 2324 bytes)
       pkts bytes target     prot opt in     out     source               destination     
      
      
      
      [root@cham002 ~]# iptables -I INPUT -p tcp --dport 80 -j DROP
      [root@cham002 ~]# iptables -nvL
      Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
       pkts bytes target     prot opt in     out     source               destination         
          0     0 DROP       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            tcp dpt:80
        532 37656 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
          0     0 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           
          0     0 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
          0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22
          0     0 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited
          0     0 DROP       tcp  --  *      *       192.168.188.1        192.168.188.128      tcp spt:1234 dpt:80
      
      Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
       pkts bytes target     prot opt in     out     source               destination         
          0     0 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited
      
      Chain OUTPUT (policy ACCEPT 17 packets, 1508 bytes)
       pkts bytes target     prot opt in     out     source               destination         
         
    

    说明: 增加一条规则,当IP192.168.188.1、协议为tcp、端口为‘1234’的向IP192.168.188.128、端口为80的机器发送包时执行操作:drop(丢掉包)。
    注: 该命令也可以把-A换成-I,两者的区别类似于排队和插队,两种方法插入的规则优先级不同。

  • 删除一条规则(-D)
    方法1: 知道规则的内容

  •   [root@cham002 ~]# iptables -D INPUT -s 192.168.188.1 -p tcp --sport 1234 -d 192.168.188.128 --dport 80 -j DROP[root@cham002 ~]# iptables -nvL
      Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
       pkts bytes target     prot opt in     out     source               destination         
        918 70764 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
          0     0 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           
          0     0 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
          0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22
          2   473 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited
        
      Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
       pkts bytes target     prot opt in     out     source               destination         
          0     0 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited
      
      Chain OUTPUT (policy ACCEPT 4 packets, 720 bytes)
       pkts bytes target     prot opt in     out     source               destination
    

 注: 要删除一条规则时,必须和写入的规则一致,也就是说,两条iptables命令除了-A/I和-D不一样外,其他地方都一样。

  • 方法2: 忘记规则内容

  • 首先所以用以下命令查看规则序号:

  •   [root@cham002 ~]# iptables -nvL --line-number
      Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
      num   pkts bytes target     prot opt in     out     source               destination         
      1     1018 77688 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
      2        0     0 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           
      3        0     0 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
      4        0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22
      5        2   473 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited
      6        0     0 DROP       tcp  --  *      *       192.168.188.1        192.168.188.128      tcp spt:1234 dpt:80
        
      Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
      num   pkts bytes target     prot opt in     out     source               destination         
      1        0     0 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited
      
      Chain OUTPUT (policy ACCEPT 41 packets, 4984 bytes)
      num   pkts bytes target     prot opt in     out     source               destination         
      
      [root@cham002 ~]# iptables -D INPUT 6
      [root@cham002 ~]# iptables -nvL --line-number
      Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
      num   pkts bytes target     prot opt in     out     source               destination         
      1     1083 82112 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
      2        0     0 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           
      3        0     0 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
      4        0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22
      5        2   473 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited
      
      Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
      num   pkts bytes target     prot opt in     out     source               destination         
      1        0     0 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited
      
      Chain OUTPUT (policy ACCEPT 5 packets, 572 bytes)
      num   pkts bytes target     prot opt in     out     source               destination      
    
  • 更改预设策略(-P)

10.11 Linux网络相关 10.12 firewalld和netfilter 10.13 netfilter5表5链介绍 10.14 iptables语法

执行命令:

# iptables -P OUTPUT DROP

结果:
10.11 Linux网络相关 10.12 firewalld和netfilter 10.13 netfilter5表5链介绍 10.14 iptables语法

注意: 尽量不要随意更改该配置,尤其是在进行远程登录时,一旦执行该命令后将会断开连接。这个策略设定后只能用命令:‘iptables -P OUTPUT ACCEPT’来恢复成原始状态,不能使用-F参数。

点赞
收藏
评论区
推荐文章
Stella981 Stella981
2年前
Linux的网卡由eth0变成了eth1或eth2,如何修复??
背景:做linux下分布式测试的时候,重新安装了两个linux虚拟机,结果分布式脚本没有做好,分布式也没有做成。     今天想练练linux命令,打开vmware,启动linux1虚拟机,使用ifconfiga,查看ip,结果没有网卡eth0显示,也没有ip,显示成了eth2。      !(https://img201
Stella981 Stella981
2年前
Centos7.x系统_网卡启动报错的案例分析
_摘要:_ 介绍了Centos7系统,网卡启动失败的两种情况,和对应的分析解决方法。介绍了Centos7系统,网卡启动失败的两种情况,和对应的分析解决方法。情景一:ifconfig 查看不到网卡ip配置,网卡没有正常启动。处理过程: 1、启动网卡systemctlstartnetwork尝试启动网卡,不能正
Stella981 Stella981
2年前
Linux之基础命令
常用命令查看ip地址的两种方式ifconfigipaddrshowLinux的两种ip地址:  127.0.0.1本机回环地址  0.0.0.0全网地址/绑定所有网卡/所有地址Linux远程连接,连接本地虚拟机服务器windows默认没有ss
可莉 可莉
2年前
10.1 使用w查看系统负载 10.2 vmstat命令 10.3 top命令 10.4 sar命令 10.5 nload命令
第十章Linux日常运维管理10.1查看系统负载w命令w命令用于显示已经登陆系统的用户列表,并显示用户正在执行的指令。执行这个命令可得知目前登入系统的用户有那些人,以及他们正在执行的程序。单独执行w命令会显示所有的用户,您也可指定用户名称,仅显示某位用户的相关信息。
Stella981 Stella981
2年前
Linux下查看网络状态的方法
  当我的设备在机房,懒得去查看网线连接情况;或者设备在远端,没有条件让眼睛亲临现场,我需要在终端查看设备网络接口的物理连接状态。基于此种场景,我就了解了几种关于命令查看网络状态的方法。  1\.ifconfig  ifconfig是Linux系统自带命令,可以查看接口配置IP的情况、临时配置接口IP(永久配置可以使用yast或者修改/et
Stella981 Stella981
2年前
CentOS7配置网卡上网、安装wget、配置163yum源
2019/09/12,CentOS7,VMware摘要:CentOS7安装完成(最小化安装)后,不能联网(已选择桥接网络),需要修改配置文件及配置yum源修改配置文件  进入网卡配置目录cd/etc/sysconfig/networkscripts  使用 ls 命令查看网卡配置文件,如下图,其中
Stella981 Stella981
2年前
CentOS7从0学起
0、CentOS官网下载DVD镜像,在virtualbox上安装,一路可视化,下一步。1、安装完成时,使用ipaddr查看网络信息,发现网卡是down状态,使用命令:ifupenp0s3(enp0s3是我的网卡),再使用ipaddr确认,虚拟机网路默认是:网络地址转换(NAT),需要改为桥接网卡,以便使用ssh等远程工具。我这里使用默认的DHC
芝士年糕 芝士年糕
1年前
Linux网络配置
在使用3A服务器期间,我们会经常使用到网络配置,下面介绍Linux网络的配置,需要服务器的可以私信我一.网络地址配置1.1网络地址查看–ifconfig命令格式:ifconfig或ifconfig网卡名主要参数信息:1.2网络配置修改临时修改IP地址ifconfig网卡更改后的IP地址language二.路由表配置2.1路由表查看–ro
胖大海 胖大海
1年前
Linux centos7 临时和永久修改IP
临时修改IPifconfigeth0192.168.13.14注意机器重启会失效!永久修改IP第一步查看需修改ip的网卡名称ifconfig第二步修改该网卡配置cd/etc/sysconfig/networkscripts第三步重启网络服务systemctlrestartnetwork这样IP地址就永久修改完成了,我这边使用的3A网
Linux查看网络流量
作为一个非职业运维,不时需要查看Linux服务器上的网络流量状况。本文介绍几个常用的Linux查看网络流量命令,并简要介绍其用法。部分命令系统已经内置,某些命令则需要从软件仓库或者自行编译安装,本文以CentOS系统为例介绍软件安装方法。查看总流量ipip命令来自iproute2util包,是查看、配置网络/路由的工具。作为ifconfig的替代品