美文网首页
linux下修改IP地址

linux下修改IP地址

作者: 有梦想的虫子_2018 | 来源:发表于2020-10-23 14:37 被阅读0次

    查看IP

    ifconfig

    [root@localhost ~]# ifconfig
    eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            ether 52:54:00:8a:fe:e6  txqueuelen 1000  (Ethernet)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.10.69  netmask 255.255.255.0  broadcast 192.168.10.255
            inet6 fe80::a00:27ff:fe94:9b6c  prefixlen 64  scopeid 0x20<link>
            ether 08:00:27:94:9b:6c  txqueuelen 1000  (Ethernet)
            RX packets 737  bytes 75483 (73.7 KiB)
            RX errors 0  dropped 2  overruns 0  frame 0
            TX packets 114  bytes 12081 (11.7 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    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 1000  (Local Loopback)
            RX packets 68  bytes 5912 (5.7 KiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 68  bytes 5912 (5.7 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    

    这里修改 eth1
    inet 192.168.10.69 id地址
    netmask 255.255.255.0子网掩码
    broadcast 192.168.10.255广播地址

    修改eth1

    • 进入 /etc/sysconfig/network-scripts/
    • 执行ls
    [root@localhost ~]# cd /etc/sysconfig/network-scripts/
    [root@localhost network-scripts]# ls
    ifcfg-eth0   ifdown-ippp    ifdown-sit       ifup-bnep  ifup-plusb   ifup-TeamPort
    ifcfg-eth1   ifdown-ipv6    ifdown-Team      ifup-eth   ifup-post    ifup-tunnel
    ifcfg-lo     ifdown-isdn    ifdown-TeamPort  ifup-ippp  ifup-ppp     ifup-wireless
    ifdown       ifdown-post    ifdown-tunnel    ifup-ipv6  ifup-routes  init.ipv6-global
    ifdown-bnep  ifdown-ppp     ifup             ifup-isdn  ifup-sit     network-functions
    ifdown-eth   ifdown-routes  ifup-aliases     ifup-plip  ifup-Team    network-functions-ipv6
    
    • 打开配置文件
    [root@localhost network-scripts]# vim ifcfg-eth1 
    
    #VAGRANT-BEGIN
    # The contents below are automatically generated by Vagrant. Do not modify.
    BOOTPROTO=static  #dhcp 动态获取IP  static 静态IP
    #dhcp
    ONBOOT=yes
    DEVICE=eth1
    NM_CONTROLLED=yes
    DNS1=114.114.114.114  #DNS解析
    IPADDR=192.168.10.69 #IP地址
    NETMASK=255.255.255.0 #子网掩码
    GATEWAY=192.168.10.1 #网关
    #VAGRANT-END
    
    • wq保存退出
    • reboot 重启linux
    [root@localhost network-scripts]# reboot
    

    相关文章

      网友评论

          本文标题:linux下修改IP地址

          本文链接:https://www.haomeiwen.com/subject/mgevmktx.html