Ubuntu/centos Network Configuration

Source: Internet
Author: User
Tags nameserver

Ubuntu Network Configuration

Configure a temporary IP

Ifconfig eth0 192.168.3.136/24

Where 24 refers to the netmask 24 bits.

Vim/etc/network/interfaces Add the following:

Auto Eth0 #开机自动连接

Iface eth0 inet Static #静态IP

Address 192.168.1.112

Netmask 255.255.255.0

Gateway 192.168.1.1

If it is DHCP, add

Auto Eth0

Iface eth0 inet DHCP

DNS configuration:

Vim/etc/resolv.conf

NameServer 202.96.128.166

NameServer 202.96.134.133

NameServer 8.8.8.8

Add the IP addresses of some DNS servers (such as telecommunications) to the resolv.conf file.

Network restart:

sudo/etc/init.d/networking restart

To turn off the network card:

sudo ifconfig eth0 down

Open Network card

sudo ifconfig eth0 up

CentOS Network Configuration

In the networ-scripts directory, different NICs correspond to different configuration files.

sudo vim/etc/sysconfig/network-scripts/ifcfg-eth0

Device=eth0

ipaddr=192.168.3.136

netmask=255.255.255.0

gateway=192.168.3.1

Hwaddr=00:0c:29:c1:78:f6

Onboot=yes #开机启动

Nm_controlled=yes

Bootproto=static

DNS Configuration

Vim/etc/resolv.conf

NameServer 202.96.128.166

NameServer 202.96.134.133

Service Restart:

sudo service network restart

Start

sudo service network start

Shut down

sudo service network stop

Ubuntu/centos Network Configuration

Related Article

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.