Linux static IP Dynamic IP settings

Source: Internet
Author: User
Tags nameserver

1. Set up dynamic IP

Ifconfig eth0 192.168.1.12

is set to take effect immediately after restarting the machine.

2. Set the static IP

Edit File/etc/sysconfig/network-scripts/ifcfg-eth0

Device=eth0

Bootproto=dhcp

Onboot=yes

hwaddr=00:0c:29:16:e5:8c

Add to:

ipaddr=192.168.1.12

netmask=255.255.255.0

gateway=192.168.1.1

Type=ethernet

Two lines, change the bootproto=dhcp to bootproto=static, note that the Bootproto value must be modified to static (static), modified after the restart of the server (reboot) to take effect, restart the network can also: Service network Restart

Ifcfg-eth0 content is as follows:

[Email protected] ~]# cd/etc/sysconfig/network-scripts/

[email protected] network-scripts]# cat Ifcfg-eth0

# Marvell Technology Group Ltd. Unknown device 4380

Device=eth0

Bootproto=static

ipaddr=192.168.1.12

netmask=255.255.255.0

gateway=192.168.1.1

Onboot=yes

#TYPE =ethernet

#DNS1 =8.8.8.8

Second, modify the gateway

Vi/etc/sysconfig/network

Networking=yes

Hostname=aaron

gateway=192.168.1.1

Third, modify the DNS

$ vi/etc/resolv.conf

NameServer 192.168.1.1

NameServer 8.8.8.8

View Network, Gateway
# IP Route Show # View Route pointing
10.211.55.0/24 Dev eth0 proto kernel scope link src 10.211.55.12
Default via 10.211.55.1 Dev eth1

# netstat-rn # Querying network data structures
# route-n # Querying network data Structures (tests are the same as Netstat display results)

1.lsmod check whether the module of the NIC is loaded to see if the NIC driver is good
2.DMESG: Check to see if the network card is detected.
3.ifup Ifdown activating/stopping network card

Linux static IP Dynamic IP settings

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.