Linux under Ifconfig, DNS, and route configuration

Source: Internet
Author: User
Tags domain name server nameserver nslookup command

Reprint: http://blog.csdn.net/wangjingfei/article/details/5283632/

It is very convenient to be familiar with Ifconfig.

ifconfig eth0 New IP

Then edit/etc/sysconfig/network-scripts/ifcfg-eth0, modify IP

First, modify the IP address

[Email protected] network-scripts]$ VI ifcfg-eth0

Device=eth0

Onboot=yes

Bootproto=static

ipaddr=219.136.241.211

netmask=255.255.255.128

gateway=219.136.241.254

Second, modify the gateway

Vi/etc/sysconfig/network

Networking=yes

Hostname=aaron

gateway=192.168.1.1

Third, modify the DNS

[Email protected] etc]$ VI resolv.conf

NameServer 202.96.128.68

NameServer 219.136.241.206

Iv. Restarting the network configuration

/etc/init.d/network restart

Modify IP Address

Immediate effect:

# ifconfig eth0 192.168.0.20 netmask 255.255.255.0

Activation takes effect:

Modify/etc/sysconfig/network-scripts/ifcfg-eth0

Modify the default gateway

Immediate effect:

# route add default GW 192.168.0.254

Activation takes effect:

Modify/etc/sysconfig/network-scripts/ifcfg-eth0

Modify DNS

Modify/etc/resolv.conf

Modified to take effect immediately, start the same effective

Modify Host Name

Immediate effect:

# hostname FC2

Activation takes effect:

Modify/etc/sysconfig/network
One. Linux Basic Network Configuration commands
1.ifconfig View the information for the network interface. Full path for normal users to use Ifconfig:/sbin/ifconfig

Ifconfig Network Interface Name: Displays detailed information for the specified interface.

Ifconfig-a View information for all network interfaces.

2. route Display routing Table

Route | grep defaults Displays the default gateway for the host.

3.ping-c 4 192.168.1.10 sends a specified number of packets for network connectivity testing.

4.traceroute 192.168.1.10 Test the network connection path to the other hosts.

5.hostname Displays the current host name.

Second, use the command network settings

1.dhclient Request a new network setting from the DHCP server.

2.ifconfig network interface IP address netmask Subnet mask: Configure the IP address, the network interface properties set by the Ifconfig command are only valid on the current system, and the network interface properties will be reconfigured after the system restarts with the contents of the network interface configuration file.

3.route del default GW defaults gateway address: Deletes the default gateway route record.

Route add default GW default gateway address: Add the Defaults gateway.

4.hostname Linserver: The host name is set to take effect immediately, and the original hostname will be restored after reboot.

5. Use the server command in the interactive mode of the nslookup command to display the DNS server addresses used in the Linux system.

6.netconfig: Character interface for network configuration.

Service Network Restart: Restart the Network service.

Ifdown Network Interface

Ifup Network interface: Restart the network interface

7. Modify the MAC address:

Ifconfig eth0 down: Disable NIC First

ifconfig eth0 hw ether 1234567890ab

Keep it that way forever:

Add these three sentences in/etc/rc.d/rc.local (you can also add the following three lines in/etc/init.d/network)

Ifconfig eth0 Down
ifconfig eth0 hw ether 1234567890ab
Ifconfig eht0 up

Third, modify the configuration file for network configuration

1. Network interface configuration file:/etc/sysconfig/network-scripts/ifcfg-eth0

/etc/sysconfig/network-scripts/ifcfg-lo

The contents of the static IP address set in the "Ifcfg-eth0" configuration file are as follows:

Device=eth0 Setting the network interface name

Onboot=yes set the network interface to be activated at system startup.

Bootproto=static configured as static address

ipaddr=192.168.1.10

netmask=255.255.255.0

gateway=192.168.1.1 default gateway for network interfaces

To obtain network configuration content using DHCP:

Device=eth0

Onboot=yes

Bootproto=dhcp

2. hostname configuration file/etc/sysconfig/network

Networking=yes

Hostname=linserver Linserver is the host name to set.

3. Local Host name resolution file/etc/hosts

4. Domain Name server configuration file/etc/resolv.conf

Search lingdian.com Set the default lookup domain name for the host

NameServer 192.168.152.2 Set the IP address of the DNS server, the file can have up to 3 "nameserver" Configuration records, one row per record, the system will first use the top "nameserver" configuration record

Basic network configuration commands for Linux

1. View Ip:ifconfig

2, the method of configuring IP:

A, this method takes effect immediately, but restarts will not be saved. (All other methods except this one can be saved)

Ifconfig eth0 1.1.1.1 netmask 255.0.0.0 up

Ifconfig eth01 1.1.1.3 up a way to set up a network card with multiple IPs (useful when setting up a virtual host)

Activating the NIC: Ifconfig eth0 up

Close network card: Ifconfig eth0 down

Dynamic acquisition of Ip:ifconfig Etho–dynamic

Dhclient

Modify Mac Value: First turn off the network card: Ifconfig eth0 down

To modify the Mac value: Ifconfig eth0 hw ether 112233445566

Re-activate the NIC: Ifconfig eth0 up

B, Netconfig or setup, but can only set Eth0 NIC

C, Neat: Open the graphics window to set

D, configuration File settings:

VI Etcsysconfignetwork-scriptsifcfg-eth0

Note: When you restart the NIC service network restart fails, use the fourth method to check if the bootup in the configuration file is None, and if DHCP is the usual error.

3. Configure the Gateway:

View Gateway: Route

To add a default route:

Route add–net 0.0.0.0 netmask 0.0.0.0 GW 192.168.0.1

To delete the default route:

Route del–net 0.0.0.0 netmask 0.0.0.0 GW 192.168.0.1

4. Configure DNS:

echo nameserver 192.168.0.1etcresolv.conf

Linux Routing configuration:

1. First turn on the routing function

Echo 1 Procsysnetipv4ip_forward (1 for open routing, 0 for off-routing feature)

(In this experiment just turn on the routing function OK)

2. Other Routing settings:

A. Add Routing information:

Route add–net 10.0.0.1 netmask 255.0.0.0 GW 192.168.0.1

or route add–net 10.0.0.1 netmask 255.0.0.0 Dev eth0 (out of the first network card on this computer)

To delete a route entry: Just change the above add to Del.

B. Configure routing with Zebra (configuration is the same as Cisco's command):

1) Set the login password:

Vi etczebrazebra.conf

Password ABC #设置连接时的密码

Enable Password 123 # set privileged passwords

2) Open Service

Service Zebra Start

3) Establish the routing protocol file to be configured

As with RIP protocol: Touch etczebraripd.conf

4) Open RIP Protocol: Service RIPD start

5) into Zebra:

Method One, Telnet 127.0.0.1 2601 # # Remember the port is 2601

If no password is set, the connection is not allowed by default and is suitable for remote login

Method Two, Vtysh # # No password can also be entered, if there is a password will also be displayed, but only for local login.

6) Configure routing: Just like in the Cisco router, it's a little bit.

7) Quit Quit (remember to save it before exiting)

#########################################

http://blog.csdn.net/liukun321/article/details/6662950

Due to the discovery of original articles, in the absence of the author and the source of the case is reproduced. I will write the author and source at the beginning of all the original articles.

I hope my friends will be reproduced in the original blog post when the article noted the author and source.

liukun321 (splashing splashing)

Original source: http://blog.csdn.net/liukun321

Found a netizen asked about the ping command appears connect:network is unreachable problem.

This is usually because the IP address is not set correctly.

Workaround:

After ensuring that the NIC driver is complete and that the NIC driver is compiled into the kernel, check

Ls/etc/sysconfig/network-script/ifcfg-eth0

First, see if there is ifcfg-eth0 this file in the above directory, if it exists, follow the steps below:

1. Manually configure the IP to see if it can be configured
Ifconfig eth0 172.18.128.143 netmask 255.255.255.0 broadcast 172.18.128.255
Route add default GW 172.18.128.1 (same network segment can not)

Or

Edit Vi/etc/sysconfig/network-scripts/ifcfg-eth0 directly

2.service Network Restart

Second, if there is no ifcfg-eth0 this file even in the/etc/sysconfig directory does not exist Network-script directory, then you need to build this directory, and create Ifcfg-eth0

The contents of the Ifcfg-eth0 file are as follows:

You only need to modify the DEVICE HWADDR NETMASK ipaddr These items according to the actual situation.

Then service network restart

Let's try to ping it.

If you're pinging a WAN instead of a local area network, make sure your gateway and DNS settings are correct

You can set the gateway by following the steps below

This command will be done.
Route add default GW 192.168.1.1

Behind that is your gateway.

Now, route.
Kernel IP Routing Table
Destination Gateway genmask Flags Metric Ref use Iface
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
Default My.router 0.0.0.0 UG 0 0 0 eth0

If not added before, only the first one above. The second one is added in the new.
If you can't access it, your situation may be a little special.

This will not be used after the reboot.
Modify
Edit/etc/network/interfaces
Add Gateway 192.168.1.1

The DNS records are in the resolv.conf file under/etc. DNS can be modified in the format of the resolv.conf file. If there is no resolv.conf, build one.

Then service network restart

Try the ping.

Linux under Ifconfig, DNS, and route 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.