1. Configure the host name to change:
Temporary method:
Hostname localhost# exit the current shell and re-login can take effect. This method can only be modified in a temporary way and fails after the system is re-established.
Permanent method:
Method 1:
Vim/etc/sysconfig/networkhostname=localhostwq!#/etc/init.d/network restart#hostname localhost tip: This will guarantee the temporary effect, The restart system also took effect.
Method 2:
Additional modification for immediate and permanent effect: Perform setup-network configuration--Edit DNS configuration-->
DNS configuration x x x Hostname localhost_______ x ===========> modify here x Primary DNS 202.106.0.20___ x x Secondary DNS 211.147.6.3____ x x Tertiary DNS _______________ x x Search _______________ x Tips : It will take effect in time after the save is changed.
2. NIC configuration file Description
Cat/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0 #这里是网卡名称第一块网卡为eth0, the second block is eth1 ... Bootproto=static #static为固定IP地址, non-dynamic DHCP gets broadcast=10.0.0.255 #这里是广播地址, typically the last address of a network address. hwaddr=00:0c:29:0e:5f:63 #mac地址, different machines cannot repeat ipaddr=10.0.0.161 # IP address netmask=255.255.255.0 #子网掩码/ 24network=10.0.0.0 #网段设置ONBOOT =yes #开机网卡自启动GATEWAY =10.0.0.254 #网关的配置, you can also add deletes by command line via the route. Type=ethernet #类型提示: The first network card is Ifcfg-eth0, the second block is ifcfg-eth1 ...
About starting the NIC Times "Device eth0 does not seem to be present" Workaround:
Use Ifconfig to see the missing eth0, only lo; ifconfig-a to see more eth1 information.
Workaround 1:
Mv/etc/sysconfig/network-scripts/ifcfg-eth0 /etcsysconfig/network-scripts/ifcfg-eth1# Change the MAC address of the eth0 to Eth1 's MAC address, changing its device name to Eth1, and then restarting the network.
Workaround 2:
Rm-rf/etc/udev/rules.d/70-persistent-net.rulesreboot in short, just ensure/etc/sysconfig/network-scripts/ifcfg-eth0 and/etc/udev /rules.d/70-persistent-net.rules information is consistent, that is, the network card address and network card number consistent, so that the service network restart can be configured successfully.
3. Modify the gateway address:
Method 1. Modify the/etc/sysconfig/networkgateway=10.0.0.254 #这个就是网关的配置方法2. Modify/etc/sysconfig/network-scripts/ ifcfg-eth0gateway=10.0.0.25 #这个就是增加网关的配置, the default is not prompt, both need to perform/etc/init.d/network restart or reload to take effect. Method 3: Modify the default gateway by command route del default GW 10.0.0.254 #首先删除之前的网关 route-n #查看命令 route add default GW 10.0.0.254 #添加默认 Gateway NOTE: This modification is temporary modification, after reloading or starting the network card will be invalidated, the solution is to try to configure in the configuration file,
4. Modify the Host DNS configuration
Method One: setup--Network configuration graphics operations
method Two: Modify/etc/resolv.conf = = "Here The path of the host DNS configuration file
NameServer 202.106.0.20nameserver 8.8.8.8nameserver 211.147.6.3 tip: Each configuration line this resolv.conf changes directly after the effective
Workarounds for/etc/resolv.conf changes after a reboot.
Workaround:
Add the Peerdns option to the/etc/sysconfig/network-scripts/ifcfg-eth<n> file. <N> can be 0, 1, 2, and so on, representing the configuration file for different NIC. For example, the first network card on the system is eth0, then its configuration file is/etc/sysconfig/network-scripts/ifcfg-eth0.
Then change the peerdns to ' no ' in the file. #PEERDNS =no This option will make the/etc/resolv.conf not be rewritten after the system restarts.
The content of the/etc/sysconfig/network-scripts/ifcfg-eth0.
device=eth0bootproto=noneonboot=yeshwaddr=08:00:27:cc:64:86netmask=255.255.255.0ipaddr=192.168.0.155gateway= 192.168.0.1type=ethernetuserctl=noipv6init=nopeerdns=no
Reference Documentation:
http://oldboy.blog.51cto.com/2561410/784625
http://oldboy.blog.51cto.com/2561410/974194
Linux system basic Network configuration