SUSE系列---修改IP和hosts文件

时间:2021-04-14 13:59:02

有些时候我们需要修改linux系统的IP,此时我们要注意,修改IP之后,如果我们如果不修改hosts文件,那么可能我们一些服务会无法使用;下面分别记录修改IP和hosts文件的方法:

修改IP:

打开:/etc/sysconfig/network/ifcfg-eth0

BOOTPROTO='static'
BROADCAST='192.168.157.255'
ETHTOOL_OPTIONS=''
IPADDR='192.168.157.130'
MTU=''
NAME=''
NETMASK='255.255.255.0'
NETWORK='192.168.157.1'
REMOTE_IPADDR=''
STARTMODE='auto'
DHCLIENT_SET_DEFAULT_ROUTE='yes'

修改hosts:

打开:/etc/hosts

# hosts         This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server.
# Syntax:
#
# IP-Address Full-Qualified-Hostname Short-Hostname
# 127.0.0.1 localhost # special IPv6 addresses
:: localhost ipv6-localhost ipv6-loopback
10.8.78.184 was2
192.168.157.130 was1 fe00:: ipv6-localnet ff00:: ipv6-mcastprefix
ff02:: ipv6-allnodes
ff02:: ipv6-allrouters
ff02:: ipv6-allhosts