zoukankan      html  css  js  c++  java
  • Linux网络基本配置命令

    修改方法:

    • 命令方式,大多是立即生效、临时有效;
    • GUI图形方式,
    • 修改配置文件,重启服务有效

    1、修改主机名

    hostname查看
    hostname name临时修改
    hostnamectl set-hostname name永久有效(cnetos7)
    centos7 /etc/hostname
    centos6 /etc/sysconfig/network

    2、网络接口配置

    • vi修改配置文件
    • ifconfig查看或设置网卡的TCP/IP参数
    [lixn@localhost ~]$ ifconfig
    enp0s31f6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500        enp0/etho第一块物理网卡    mtu分组的最大传送单元  flags网络接口状态up....(活动)
            inet 192.168.1.125  netmask 255.255.255.0  broadcast 192.168.1.255   inet/inet addr网卡的IP地址   netmask/Mask子网掩码    boadcast/bcast广播地址
            inet6 fe80::c133:9f47:a9f:66  prefixlen 64  scopeid 0x20<link>    ine网卡IPv6
            ether c8:5b:76:25:af:01  txqueuelen 1000  (Ethernet)          ether/Hwaddr网卡的物理地址mac地址  txqueuelen传送队列的长度
            RX packets 4673305  bytes 3223334449 (3.0 GiB)             RX packets接受的数据包总数
            RX errors 0  dropped 0  overruns 0  frame 0               
            TX packets 2439350  bytes 305949223 (291.7 MiB)             TX packets发送的数据包总数
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
            device interrupt 16  memory 0xe1300000-e1320000  
    
    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 45571  bytes 3060724 (2.9 MiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 45571  bytes 3060724 (2.9 MiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    wlp1s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
            ether b8:81:98:5a:7f:17  txqueuelen 1000  (Ethernet)
            RX packets 1284454  bytes 1267419395 (1.1 GiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 913186  bytes 155893700 (148.6 MiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    当前有3个网络接口信息,一个是enp0是系统的第一块网卡信息;lo代表loopback环回接口,是Linux内部通信的基础,IP始终为127.0.0.1;
    ifconfig 网卡名 <IP地址> netmask <子网掩码>  此命令会立即生效,但不会修改配置文件。
    ifconfig eth0 192.168.1.10 netmask 255.255.255.0  设置网卡
    ifconfig eth0:1 192.168.1.10 netmask 255.255.255.0  eth0:1为设置虚拟网卡
    

     mac地址,全球唯一,由网络设备制造商生产时写入网卡内部。mac地址长度为48位的十六进制数,用冒号分割 c8:5b:76:25:af:01,前六为为网卡制造商编号,后六位为系列号。要更改mac地址,需要先禁用该网卡,然后使用ifconfig

    ifconfig 网卡名 down禁用网卡
    ifconfig 网卡名 hw ether c8:5b:76:25:af:01修改网卡
    ifconfig 网卡名 up启用网卡

    永久修改网卡配置文件要去/etc/sysconfig/network-scripts/ifcfg-eth0, 然后重启网络服务network

    ip addr命令看到的是啥??

    此外还有图形配置方法!(菜单; system-config-network命令; system-config-network-tui命令)



  • 相关阅读:
    修改VNC的分辨率
    How to use WinSCP with public key authentication
    CentOS-7-x86_64-DVD-1511.iso
    6.828
    Tampermonkey版Vimium
    servlet+jsp完成简单登录
    Servlet知识点小结
    HTTP基础知识点小结
    LeetCode 371两数之和
    LeetCode53 最大子序列问题
  • 原文地址:https://www.cnblogs.com/daduryi/p/6657202.html
Copyright © 2011-2022 走看看