Linux Network parameter Configuration

Source: Internet
Author: User
Tags nameserver

First, network configuration

Solution for resolving clone virtual machine NIC name non-eth0

Vim/etc/udev/rules.d/70-persistent-net.rules

Delete the Name=eth0 line

#PCI device 0x8086:0x100f (e1000)
subsystem== "NET", action== "Add", drivers== "? ", attr{address}==" 00:0c:29:45:40:a3 ", attr{type}==" 1 ", kernel==" eth", name=" eth0 "

Change the remaining last line name=ethx to Name=eth0

#PCI device 0x8086:0x100f (e1000)
subsystem== "NET", action== "Add", drivers== "? ", attr{address}==" 00:0c:29:45:40:a3 ", attr{type}==" 1 ", kernel==" eth", name=" eth1 "(modified to Eth0)

Reboot

1. View

1) IP A//Simple view network card IP address information

2:eth0 (ETH on behalf of Ethernet, 0 for the first NIC): <BROADCAST,MULTICAST,UP,LOWER_UP> MTU Qdisc Pfifo_fast State up (current NIC is working properly, Down indicates that the NIC is not enabled or not configured Ip,unknown represents a network card exception or network cable problem, and IP configuration error Qlen 1000
Link/ether 00:0c:29:45:40:a3 (the MAC address of the current network card) BRD FF:FF:FF:FF:FF:FF (the Mac broadcast address of the current network card)
inet 192.168.10.167/24 (IP address of the current network card) BRD 192.168.10.255 (the broadcast address of the current IP) scope global eth0
Inet6 FE80::20C:29FF:FE45:40A3/64 (IPV6 address of current NIC) scope link
Valid_lft Forever Preferred_lft Forever

2) Ifconfig//Detailed View network card IP address information

Eth0 Link encap:ethernet HWaddr 00:0c:29:45:40:a3 (the MAC address of the current network card)
inet addr:192.168.10.167 (IP address of the network card) bcast:192.168.10.255 (the broadcast address of the network card) mask:255.255.255.0 (subnet mask of the network card)
Inet6 ADDR:FE80::20C:29FF:FE45:40A3/64 (IPV6 address of the network card) Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:1528 errors:0 dropped:0 overruns:0 frame:0 (number of packets sent)
TX packets:283 errors:0 dropped:0 overruns:0 carrier:0 (number of accepted packets)
collisions:0 txqueuelen:1000
RX bytes:906220 (884.9 KiB) (the total size of the sending packet) TX bytes:39462 (38.5 KiB) (the total size of the received packet)

3) IP r//view routing information (default this behavior defaults to gateway address)

The gateway address of the default via 192.168.10.1 dev eth0//eth0 network card is 192.168.10.1

4) route-n//View routing information

Destination Gateway genmask Flags Metric Ref use Iface
0.0.0.0 192.168.10.1 0.0.0.0 UG 0 0 0 eth0

Destination network Segment gateway address destination subnet Mask Routing State (U for up, G for Gateway, H for host) egress NIC

5) cat/etc/resolv.conf//View DNS information (store domain name-->IP correspondence)

NameServer 192.168.3.5

6) hostname//view current hostname (identifies host role)

2. Configuration

Temporary (effective immediately, but lost after reboot)

1) IP a Add IP address/subnet mask dev NIC device//Add IP address to the specified NIC

Cases:

IP a add 192.168.10.222/24 dev eth0//Add a IP,IP to the eth0 NIC for 192.168.10.222/24

2) ifconfig network card set IP address/subnet mask//Set network card IP address, the original IP is overwritten

Cases:

Ifconfig eth0 192.168.10.111/24

Note: The IP and ifconfig configuration commands are clearly different, IP is new on the original IP, and Ifconfig replaces the original IP address

3) route Add default GW gateway address dev NIC Settings//Specify network card temporarily set gateway address

Cases:

Route add default GW 192.168.10.1 dev eth0//configure eth0 NIC gateway to 192.168.10.1

4) vim/etc/resolv.conf//Configure the current host DNS server address

NameServer DNS Address

Note: nameserver general configuration Two, the system will be read from the top, only when the previous one does not work, only switch to the next DNS server

5) hostname hostname && BASH//temporarily set host name

Cases:

Hostname ftp.xueluo.org && Bash//temporarily set the current host name to Ftp.xueluo.org

6) IP a del IP address/subnet mask dev NIC device//Remove NIC IP address specified

Cases:

IP a add 192.168.10.111/24 dev eth0//Add 192.168.10.111 IP address on eth0 NIC

IP a del 192.168.10.111/24 dev eth0//Remove the 192.168.10.111 IP address on the eth0 NIC

7) Route del default GW gateway address dev NIC set//temporarily delete default gateway for specified NIC

Cases:

Route del default GW 192.168.10.1 dev eth0//temporarily remove Eth0 network card gateway address

Permanent (takes effect after reboot, but still exists after reboot)

IP Address

1) Vim/etc/sysconfig/network-scripts/ifcfg-eth0//Modify the network card configuration file

Device=eth0//Network card device
Type=ethernet//NIC type
Onboot=yes//Start-up
Nm_controlled=no//Disable NetworkManager
Bootproto=static//network card is static mode
ipaddr=192.168.10.111//Network card IP
netmask=255.255.255.0//Net clip netmask
gateway=192.168.10.1//Network card gateway address
Preferred DNS for dns1=192.168.3.5//NIC
Alternate DNS for dns2=114.114.114.114//NIC

2) Reboot | Service Network Restart | /etc/init.d/network restart

Host Name

1) vim/etc/sysconfig/network

Networking=yes
hostname=ftp.xueluo.org//Host name of the current system

2) reboot

Second, DHCP

2. Use

1) Reduce Administrator workload

2) Prevent IP address collisions

Note: The DHCP server must be a static IP address, only the same network segment DHCP information can be issued

2. Working principle

1) Discovery: Client sends broadcast request, request DHCP server address

2) OFFER:DHCP server responds to client broadcast request (responds to its own IP address)

3) Request: Client requests IP address from DHCP server

4) ACK:DHCP server assigns IP to client and determines lease (300s)

3. Lease time

Renew

When client use time reaches 1/2, the client needs to continue to use the IP address, the client sends a renewal request to the DHCP server, the DHCP server responds, and the renewal succeeds

Note: If the maximum lease time is reached (the default is 7,200 seconds), the DHCP server will no longer renew the contract, if the client needs to continue to use the IP address, then a new IP is assigned to the client to use

Do not renew

When the client uses a time of 1/2 and the client does not continue to use the IP address, the DHCP server reclaims the IP address after the time of arrival

Third, build DHCP

Installation

1.IP Configuration

1) Vim/etc/sysconfig/network-scripts/ifcfg-eth0

Device=eth0
Type=ethernet
Onboot=yes
Nm_controlled=no
Bootproto=static
ipaddr=192.168.1.10
netmask=255.255.255.0

2)/etc/init.d/network Restart | Service Network Restart | Reboot

2. Install the DHCP package

1) rpm-ivh/mnt/packages/portreserve-0.0.4-9.el6.x86_64.rpm

2) rpm-ivh/mnt/packages/dhcp-4.1.1-49.p1.el6.centos.x86_64.rpm

Configuration

1) cp/usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample/etc/dhcp/dhcpd.conf//Copy DHCP configuration file template

2)/etc/dhcp/dhcpd.conf

:% g/^#/d//delete all lines beginning with # in a file
:% g/^$/d//Delete all empty lines in file

Option Domain-name "xuyeluoyue.com"; The domain name issued
Default-lease-time 28800; Default Lease Time
Max-lease-time 36000; Maximum lease time
Log-facility Local7; Logging devices and Levels
Subnet 192.168.1.0 netmask 255.255.255.0 {//Issued network segment and subnet mask
Range 192.168.1.100 192.168.1.200; Range of IP addresses issued
Option broadcast-address 192.168.1.255; IP broadcast address issued by
}

3) dhcpd-f//Check/etc/dhcp/dhcpd.conf file for errors

Start

1) Service dhcpd start &&/etc/init.d/dhcpd start && reboot

2) chkconfig--level dhcpd on

Reserved address

1)/etc/dhcp/dhcpd.conf

Host hehe {
Hardware ethernet? 00-0c-29-06-b6-5b;//Client MAC Address
Fixed-address 192.168.1.10; Reserved IP Address
}

2) Service DHCPD restart &&/etc/init.d/dhcpd restart && reboot

Linux Network parameter Configuration

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.