1. The ifconfig command is temporarily modified.
Ifconfig is used to configure the IP address of the NIC. It takes effect after modification, but is not saved. It becomes invalid after the next startup.
# Ifconfig-a ---> obtain the name of the NIC. Generally, the first M Nic is named hme0.
# Ifconfig hme0 down ---> stop the service of the NIC hme0 temporarily
# Ifconfig hme0 192.168.1.100 netmask 255.255.255.0 up ---> Start the NIC
2. Change the IP address permanently
You need to modify the following files:
/Etc/hosts add machine name and IP address
Example: 192.168.1.100 www.guanwei.org
/Etc/netmasks add to Subnet
Example: 192.168.1.0 255.255.255.0
/Etc/hostname. hme0 change the IP address of the NIC
Example: 192.168.1.100
/Etc/defaultrouter add to Gateway
Example: 192.168.1.1
/Etc/resolv. conf add to DNS Server
For example:
Nameserver 202.106.0.20
Nameserver 202.106.196.115
Modify the/etc/nsswitch. conf file.
Find this line of hosts: files
Change to hosts: files dns
That is, if the domain name cannot be found in/etc/hosts, it will go to DNS resolution.
After the modification is complete, reboot and restart.
========================================================== ========
If the NIC is changed or the NIC is added, the interface service cannot be started automatically. You need to manually create the NIC service:
# Ifconfig hme0 plumb
You can create a network port service for the interface hme0.
Correspondingly, the ifconfig with the unplumb parameter can be used to stop the service and disable the network.
From: guanwei blog