zoukankan      html  css  js  c++  java
  • IP ,路由

    ifconfig 命令
     
     
     
    ip信息
     
    enp0s3: flags=4163<UP(已经启用),BROADCAST(支持广播),RUNNING,MULTICAST(支持多播)> mtu 1500
    inet 192.168.23.11 netmask 255.255.255.0 broadcast 192.168.23.255
    inet6 fe80::a00:27ff:fec1:cd2b prefixlen 64 scopeid 0x20<link>
    ether 08:00:27:c1:cd:2b txqueuelen 1000(传输队列长度) (Ethernet)
    RX(接受的数据包) packets 28355 bytes 10835366 (10.3 MiB)
    RX errors(错误包数量) 0 dropped(丢包数量) 0 overruns 0 frame 0
    TX(传出的数据包) packets 15286 bytes 2489410 (2.3 MiB)
    TX errors(错误包数量) 0 dropped(丢包数量) 0 overruns 0 carrier 0 collisions 0

     

    ifconfig命令使用(设置IP地址可以立即生效)
    1)显示激活网卡,以及网络信息
    ifconfig
     
    2)显示激活网卡,以及网络信息
    ifconfig eth0
     
    3)显示所有网卡,以及网络信息
    ifconfig -a
     
    4)启用网卡地址
    ifconfig eth0 up
    ifconfig enp0s3 up
     
     
    5)停止网卡地址
    ifconfig eth0 down
    ifconfig enp0s3 down
     
    6)网卡取别名的两种写法
    ifconfig eth0:0 192.168.23.10/24
    ifconfig enp0s3:0 192.168.23.100 netmask 255.255.255.0 broadcast 192.168.23.255
     
     
     
    • (2)route命令
    1:增
    添加主机地址路由
    route add -host 192.168.24.100 gw 192.168.23.1 dev eth0
     
    添加网络地址路由
    route add -net 192.168.24.0/24 gw 192.168.23.1 dev eth0
     
    添加默认地址路由
    route add -net 0.0.0.0/0.0.0.0 gw 192.168.23.1 dev eth0
     
    2:删
    删除主机地址路由
    route del -host 192.168.24.100
     
    删除网络地址路由
    route del -net 192.168.24.0/24
     
    删除默认地址路由
    route del default
    3:改
    先删除,再修改
     
    4:查
    route -n
    Kernel IP routing table
     
    Destination(目的地址) Gateway(网关,吓一跳) Genmask(子网掩码) Flags Metric Ref Use Iface(接口)
    192.168.23.0 0.0.0.0(同一个网段无需网关) 255.255.255.0 U 0 0 0 eth0
    192.168.23.0 0.0.0.0 255.255.255.0 U(up:表示启用状态) 0 0 0 eth1
    169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
    0.0.0.0 192.168.23.1 0.0.0.0 UG(G表示网关) 0 0 0 eth0
    • (3)netstat命令(对应的ss命令请自行总结)
    会经常使用
    必备技能:netstat -lntup
    -u:UDP
    -t:TCP
    -l:查看监听状态
    -n:以数字的形式显示
    -p:显示进程、服务名称
    -a:显示all信息
     
    [root@6 ~]# netstat -lentupa
    Active Internet connections (servers and established)
    Proto(协议) Recv-Q(接收) Send-Q(发送) Local Address(本地监听的套接字) Foreign Address(客户端连接的套接字) State(进程状态) User(用户的id) Inode(文件的inode号) PID/Program name
    tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 9197 1090/sshd
    tcp 0 0 192.168.23.4:22 192.168.23.2:65106 ESTABLISHED 0 9567 1191/sshd
    tcp 0 0 :::22 :::* LISTEN 0 9199 1090/sshd
    udp 0 0 0.0.0.0:68 0.0.0.0:* 0 8497 856/dhclient
    • (4)ifup、ifdown命令
    需要添加/etc/sysconfig/network-scripts/ifcfg-eth1网卡配置文件,才能给ifup、ifdown控制
     
    ifup eth1
    ifdown eth1
  • 相关阅读:
    Python命名规范
    安装pywin32模块
    深度学习框架
    更快速的学习掌握新知识
    使用 Docker + SSH代理 来实现访问内网网站
    magento Too many arguments, expected arguments "command".
    使用 Prestissimo 提高 composer 下载速度
    使用Lebab 将 Javascript ES5 转 ES6
    分享网络上学习英语的方法或技巧
    使用 Expo 的错误 WebSocket connection to 'ws://localhost:19002/debugger-proxy?role=debugger&name=Chrome' failed: Error during WebSocket handshake: Unexpected response code: 400
  • 原文地址:https://www.cnblogs.com/liu1026/p/7498031.html
Copyright © 2011-2022 走看看