zoukankan      html  css  js  c++  java
  • 怎么将linux的动态IP设置成静态IP

    例如我的eth0网卡信息如下

    eth0      Link encap:Ethernet  HWaddr 00:0C:29:AA:B2:CA  
              inet addr:192.168.79.135  Bcast:192.168.79.255  Mask:255.255.254.0
              inet6 addr: fe80::20c:29ff:feaa:b2ca/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:208685 errors:0 dropped:0 overruns:0 frame:0
              TX packets:53443 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:42393010 (40.4 MiB)  TX bytes:18010745 (17.1 MiB)

    现在我想把我的本地IP固定成192.168.79.133(用虚拟机的童鞋都知道,IP老是变化好麻烦)

    1.查看网关地址,我的是192.168.79.2

    [root@zongbh-centos6 ~]# route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.78.0    0.0.0.0         255.255.254.0   U     1      0        0 eth0
    0.0.0.0         192.168.79.2    0.0.0.0         UG    0      0        0 eth0

    2.查看DNS,我的是192.168.79.2

    [root@zongbh-centos6 ~]#  cat /etc/resolv.conf
    # Generated by NetworkManager
    search 7
    nameserver 192.168.79.2

    3.配置网卡信息,我的是 vim /etc/sysconfig/network-scripts/ifcfg-eth0

       配置信息如下

    DEVICE="eth0"IPV6INIT="yes"
    NM_CONTROLLED="yes"
    ONBOOT="yes"
    TYPE="Ethernet"BOOTPROTO=static
    DNS1=192.168.79.2
    IPADDR=192.168.79.133
    NETMASK=255.255.254.0
    GATEWAY=192.168.79.2
  • 相关阅读:
    HDOJ 1093
    HDOJ 1089
    HDOJ 1094
    qsort函数
    HDOJ 1092
    HDOJ 1091
    NYOJ 448(贪心)
    HDOJ 1090
    HDOJ 1097(幂取模)
    winform用户输入查询与拼音首字母的结合,提高用户的操作体验
  • 原文地址:https://www.cnblogs.com/xiaozong/p/7070015.html
Copyright © 2011-2022 走看看