Linux Static IP Settings __linux

Source: Internet
Author: User
Tags nameserver

Linux Static IP Settings


http://weilaisecond.blog.163.com/blog/static/115927600201082243642682/

IP configuration:
/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0
Bootproto=static
Hwaddr=00:26:18:0b:38:c0
Onboot=yes
ipaddr=192.168.0.20
netmask=255.255.255.0
gateway=192.168.0.1
IP takes effect:
/sbin/ifdown eth0
/sbin/ifup eth0

Notification Gateway Update information:
/etc/init.d/network restart

To configure DNS:
Vi/etc/resolv.conf
NameServer 202.96.134.133

Resolve reboot Effective:
Chattr +i/etc/resolv.conf
Change to read-only

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 device=name name indicates the names of the physical devices
ipaddr=x.x.x.x ipaddr=addr addr Represents the IP address assigned to the card
netmask=255.255.255.0 Netmask=mask Mask represents a network mask
network=x.x.x.x NETWORK=ADDR Addr Represents the network address
broadcast=x.x.x.x BROADCAST=ADDR addr Represents broadcast address
Onboot=yes whether the card is activated when onboot=yes/no is started
Bootproto=none None: No need to start protocol BOOTP: using BOOTP protocol DHCP: using DHCP protocol
Userctl=no userctl=yes/no whether to allow non-root users to control the device

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.

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.
V. Concluding remarks
To sum up, as long as the use of any one of the methods, the definition of host name, host table, network interface equipment and routing parameters, configure a good Linux Ethernet, you can access the Internet, enjoy the services provided by the Internet.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.