This article introduces, in Linux set the IP address, gateway, DNS method, have the need for friends to make a reference bar.
There are two ways to set up a Linux network:
First: Use the command to modify (direct immediate effect)
Copy Codecode example:
IP and netmask:
# ifconfig eth0 192.168.30.197 netmask 255.255.255.0
Gateway
# route Add default GW 192.168.30.1 eth0
Dns:
# VI Etc/resolv.conf
NameServer 202.131.80.1
NameServer 202.131.80.5
Second: Modify the configuration document (need to restart the network configuration)
First, modify the IP address
Copy Codecode example: [[email protected] network-scripts]$ VI ifcfg-eth0
Device=eth0
Onboot=yes
Bootproto=static
ipaddr=192.168.30.197
netmask=255.255.255.0
gateway=192.168.30.1
Second, modify the gateway
Vi/etc/sysconfig/network
Copy Codecode example: Networking=yes
Hostname=aaron
gateway=192.168.30.1
Third, modify the DNS
Copy Codecode example: [[email protected]db1 etc]$ VI resolv.conf
NameServer 202.131.80.1
NameServer 202.131.80.5
(This is usually set to restart the network later, so it also involves the restart configuration)
Iv. Restarting the network configuration
There are several ways to do this:
Copy Codecode example: 1:root Account # Service Network restart
2:#/etc/init.d/network Restart
3:# Ifdown eth0
# ifup Eth0
4:# ifconfig eth0 Down
# ifconfig eth0 up
V. Start and close the firewall
Immediate effect:
Copy Codecode example: 1: #service iptables start
#service iptables Stop
Restart the system to take effect:
Copy Codecode example: 2: #service iptables on
#service iptables off
Linux Set IP address GW Gateway, DNS method