Set the ip address of the linux system in the virtual machine

  1. linux vi save instruction

     

    Press ESC to jump to command mode, then:

  2. :w save file without exiting vi
    :w file additionally save changes to file without exiting vi
    :w! force save without exiting vi
    :wq save file and exit vi
    :wq! force save file and exit vi
    q: Do not save the file, exit vi
    :q! Do not save the file, force quit vi
    :e! Abandon all changes, start editing from the last time the file was saved 

     

     

     

    Use the root user to log in to linux and open the terminal

     
  3.  

    In terminal enter: vi /etc/sysconfig/network-scripts/ifcfg-eth0

     
  4.  

    After returning,

    Start editing, fill in the ip address, subnet mask, gateway, DNS, etc.

    ONBOOT=yes Boot automatically
    BOOTPROTO=static static ip
    DNS1=192.168.1.1 dns
    IPADDR=192.168.3.235 ip address
    NETMASK=255.255.255.0 subnet mask
    GATEWAY=192.168..3.1 gateway
  1.  

    After editing, save and exit Note: How to exit and save: Press esc ->Shift+: ->wq

    restart network service

    service network restart或/etc/init.d/network restart

    Then ping the gateway and ping the external network for testing. All pings indicate that the network is normal

     
  2.  

    Detailed summary:

    ---Modify ip address---

    Immediately effective:

    # ifconfig eth0 192.168.1.155 netmask 255.255.255.0

    Restart to take effect:

    修改vi /etc/sysconfig/network-scripts/ifcfg-eth0

    ---Modify default gateway---

    Immediately effective:

    # route add default gw 192.168.1.1

    Restart to take effect:

    修改vi /etc/sysconfig/network-scripts/ifcfg-eth0

    ---Modify dns---

    Modify vi /etc/resolv.conf

    The modification takes effect immediately, and restart is also effective

    ---Modify host name---

    Immediately effective:

    # hostname test1

    Restart to take effect:

    Modify vi /etc/sysconfig/network

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326790483&siteId=291194637