Linux Settings Gateway and IP
Modify IP Address
Immediate effect:
# ifconfig eth0 192.168.0.20 netmask 255.255.255.0
Start in effect:
Modify/etc/sysconfig/network-scripts/ifcfg-eth0
Modify the default gateway
Immediate effect:
# route add default GW 192.168.0.254
Start in effect:
Modify/etc/sysconfig/network-scripts/ifcfg-eth0
Modify DNS
Modify/etc/resolv.conf
Can be effective immediately after modification
Modify Host Name
Immediate effect:
# hostname FC2
Start in effect:
Modify/etc/sysconfig/network
ETC/SYSCONFIG/NETWORK-SCRIPTS/IFCFG-ETHN file
In Redhat, the configuration file for the system network device is saved under the "/etc/sysconfig/network-scripts" directory, Ifcfg-eth0 contains the configuration information for the first network card, and the configuration information that contains the second network card.
The following is an example of a "/etc/sysconfig/network-scripts/ifcfg-eth0" file:
Device=eth0
ipaddr=x.x.x.x
netmask=255.255.255.0
network=x.x.x.x
broadcast=x.x.x.x
Onboot=yes
Bootproto=none
Userctl=no
If you want to manually modify the network address or add a new network interface to the new interface, you can do so by modifying the corresponding file (IFCFG-ETHN) or by creating a new file.
Device=name name indicates the names of the physical devices
Ipaddr=addr addr represents the IP address assigned to the card
Netmask=mask Mask represents a network mask
NETWORK=ADDR addr represents the network address
Broadcast=addr addr Represents broadcast address
Onboot=yes/no whether the card is activated at startup
None: No need to start protocol
BOOTP: Using BOOTP protocol
DHCP: Using DHCP protocol
Userctl=yes/no whether to allow non-root users to control the device
The manual use of the command method is based on the Ethernet card is mounted in the case of editing the configuration file to configure the network method. The specific steps are as follows:
⑴ Edit/etc/rc.d/rc.local File
Include the following lines in the file:
#配置第一个以太网卡eth0的IP地址, subnet mask, up activate
/sbin/ifconfig,etho 163.1.5.125 netmask 255.255.0.0 up
#配置并激活回环设备lo
/sbin/ifconfig Lo 127.0.0.1 up
/sbin/route add–host 127.0.0.1 Lo
#让Linux将本地网的信息发送到eth0接口
/sbin/route add–net 163.1.5.125 netmask 255.255.0.0 eth0
#指定访问远程网络的缺省网关, assume that the IP address of the default gateway is 163.1.1.254
/sbin/route default GW 163.1.1.254 eth0
⑵ Edit/etc/resdv.conf File
The file role is to set the name server. You can add the following content.
#指定本机域名为linux. Net.
Domain linux.net
#域名称服务器 (DNS), either a local or remote network. Look in the order of nameserver. If not found, Linux gives up looking.
Nameserver 163.1.1.4
Nameserver 10.55.0.33
⑶ Edit/etc/hosts.conf File
Sets the host file table. You can add the following lines:
Order Hosts,bind
Multi on
163.1.5.125 lgx.linux.net LGX
The first line indicates that when you look up a name, you first check the local host file (hosts) and then follow the nameservers order specified by/etc/resolv.conf.
Third, the host IP address, host name and alias.
After editing three files for/etc/rc.d/rc.local,/etc/hosts.conf,/etc/resolv.conf, you must restart the machine.