zoukankan      html  css  js  c++  java
  • Linux 网络配置

    快速配置命令

      ifconfig  网卡名字  地址 / 掩码长度(重启后失效)

      ifconfig  网卡名字 up  启用网卡

      ifconfig  网卡名字 down  禁用网卡

     可以为一张网卡配置多个IP地址

      ifconfig  网卡名字:数字   地址

    网络服务

      /etc/init.d/network { start | stop | restart | status }

      /etc/init.d/network-manager { start | stop | restart |status }

    网关

      route命令 (网络重启失效)

    eko@ubuntu:/etc/init.d$ route
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    default         192.168.1.254   0.0.0.0         UG    100    0        0 ens33  #默认/缺省路由
    192.168.1.0     *               255.255.255.0   U     100    0        0 ens33

      -add : 添加

        -host : 主机路由

        -net : 网络路由

          -net  0.0.0.0

    root@ubuntu:~# route add 10.0.0.1(目标地址) gw 192.168.1.1(下一跳)
    root@ubuntu:~# route add default gw 192.168.1.254 添加默认路由

      -del:删除

        -host

        -net

    root@ubuntu:~# route del 10.0.0.1

    配置文件

      /etc//network/interfaces

    编辑 /etc/network/interface文件如下

    auto lo
    iface lo inet loopback
    auto eth0
    #如果是自动获取ip,添加
    iface eth0 inet dhcp
    #如果是手动配置ip,添加
    iface eth0 inet static
    address xxx.xxx.xxx.xxx  #ip地址  
    netmask xxx.xxx.xxx.xxx  #子网掩码
    network xxx.xxx.xxx.xxx  
    boardcast xxx.xxx.xxx.xxx  #广播地址
    gateway xxx.xxx.xxx.xxx  #网关

     

    DNS服务器配置

    /etc/resolvconf.conf
    nameserver 8.8.8.8
    nameserver 8.8.4.4

    本地解析

     / etc / hosts   和Windows下  C:WindowsSystem32driversetchost 文件作用一致

    127.0.0.1   localhost
    127.0.1.1   ubuntu
    #添加一条
    192.168.1.24  www.eko.com 

    网卡名称

    lo:本地回环

    eth [0-9]:以太网网卡,有时候也被识别成另外的名字

        eno1:代表由主板bios内置的网卡

    ens1:代表有主板bios内置的PCI-E网卡

    enp2s0: PCI-E独立网卡

    eth0:如果以上都不使用,则回到默认的网卡名

  • 相关阅读:
    T4模板使用记录,生成Model、Service、Repository
    sortablejs + vue的拖拽效果 列表个数不固定 刷新后保持拖拽后的效果
    vue获取input焦点,弹框后自动获取input焦点
    vue proxy 跨域代理
    vue 同步 $nextTick setTimeout 执行的顺序
    js手写日历插件
    js数组随机排序
    vue自定义插件
    elementui 自定义表头 renderHeader的写法 给增加el-tooltip的提示
    awit的用法,等待执行结果
  • 原文地址:https://www.cnblogs.com/xiaoliwang/p/9027313.html
Copyright © 2011-2022 走看看