The first thing to do after installing Linux is to set an IP address to access the internet. This article describes how. set static IP addresses. (1 ). command line setting (this method is only temporary setting and will expire after the system is restarted) [1]. set IP address and mask ifconfig interface name (such as eth0) IP address netmask...
The first thing to do after installing Linux is to set an IP address for Internet access. This article describes how
. Set static IP address.
(1). set the command line (this method is only temporary and will not expire after the system is restarted)
[1]. set IP address and mask
Ifconfig interface name (such as eth0) IP address netmask subnet mask
[2]. set the Gateway
Route add default gw default gateway
[3]. set the DNS server address
Echo "nameserver DNS server address">/etc/resolv. conf
Instance: assume that the IP address of eth0 is 192.168.1.100 and DNS is 192.168.1.12.
Ifconfig eth0 192.168.1.100 netmask 255.255.255.0
Route add default gw 192.168.1.1
Echo "nameserver = 192.168.1.12">/etc/resolv. conf
(2). modify the file to configure the network (you need to restart the network interface)
[1]. modify the IP address. File:/etc/sysconfig/network-scripts/ifcfg-interface name
Assume that the network interface name is eth0.
Cat < /Etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE = eth0 (note: the network interface name is entered here)
BOOTPROTO = none
ONBOOT = yes (note: whether to start with the system)
IPADDR = 192.168.1.100 (note: the IP address is entered here)
PREFIX = 24 (note: The mask length is entered here)
GATEWAY = 192.168.1.1 (note: The GATEWAY is written here)
EOF
[2]. modify DNS
Echo "nameserver DNS server address">/etc/resolv. conf
[3]. restart the network interface (assuming eth0)
Ifup eth0 (note: The Interface name is written here)
Author: "huangyandong"