Organize Centoos,suse,ubuntu version of Linux network configuration

Source: Internet
Author: User
Tags nameserver

CentOS Network Configuration

Environment:

System hardware: VMware vsphere (cpu:2*4 kernel, memory 2G)

System version: centos-6.5-x86_64

Router Gateway: 192.168.1.1

Steps:

1. View the network MAC address
[Root@centos ~]# Cat/etc/udev/rules.d/70-persistent-net.rules

Displays the following information
# PCI Device 0x15ad:0x07b0 (VMXNET3)
subsystem== "NET", action== "Add", drivers== "? *", attr{address}== "00:50:56:94:04:3c", attr{type}== "1", kernel== "eth*" , name= "Eth0"

# PCI Device 0x15ad:0x07b0 (VMXNET3)
subsystem== "NET", action== "Add", drivers== "? *", attr{address}== "00:50:56:94:53:24", attr{type}== "1", kernel== "eth*" , name= "Eth1"

Eth0: Corresponding to the first card, eth1: On the second net card. Currently using eth0 to connect the router, eth1 reserved (the server is typically used to connect to other hosts)


2. Modify Host Name
[Root@centos ~]# Vim/etc/sysconfig/network


Open the file, modify the following content, and save

Networking=yes #使用网络
Hostname=centos #设置主机名称

3. Modify the network card
[Root@centos ~]# Vim/etc/sysconfig/network-scripts/ifcfg-eth0


Open the file, modify the following content, and save

Device=eth0 #对应第一张网卡
Type=ethernet
Onboot=yes #是否启动时运行
Nm_controlled=yes
Bootproto=static #使用静态IP instead of being assigned IP by DHCP
Defroute=yes
Ipv4_failure_fatal=yes
Ipv6init=no
Name= "System eth0" #名称
hwaddr=00:50:56:94:04:3c #必须对应etho是的MAC地址 (/etc/udev/rules.d/70-persistent-net.rules)
Peerdns=yes
Peerroutes=yes
ipaddr=192.168.1.40 #指定本机IP地址
netmask=255.255.255.0 #指定子网掩码
gateway=192.168.1.1 #指定网关

4. Modify DNS
[Root@centos ~]# vim/etc/resolv.conf

Open the file, modify the following content, and save
NameServer 8.8.8.8 #GOOGLE的DNS服务器
NameServer 61.144.56.100 #指定当前城市最近的DNS服务器 (different cities, internet search)
NameServer 192.168.1.1 #指定经路由器上指定的DNS服务器


5. Restart Network configuration
[Root@centos ~] #service Network restart



6. Reboot

[Root@centos ~] #shutdown-R now

7. View current IP Settings

[Root@centos ~]# Ifconfig

8. Test whether to connect the external network

[Root@centos ~]# Ping www.163.com

Ubuntu Network Configuration

One, the configuration is roughly divided into three categories: through configuration file configuration, through the command configuration, through the Graphical Network connection menu configuration.

Dial-up Wireless and so on no condition experiment, does not involve.

Main file:/etc/network/interfaces, here are some configuration of IP, gateway, mask, etc./etc/resolv.conf this file to save information about DNS

Main command: sudo/etc/init.d/networking Restart restart the network to disable configuration file configuration, sudo route add default GW <IP address, set the gateway.

Second, the configuration method

1, through the command configuration

If you just want to modify the IP address temporarily, you can choose this method. It will be lost when you restart the network.

1 sudo ifconfig eth0 <ip address > netmask < subnet mask > up

Eth0 is the NIC. The last up means to open the network card, you can not add.

2 sudo route add default GW < Gateway Ip>

Setting up Gateways
3 Set DNS, this must go to config file modification, same as the second kind

4) Configure the host name

Command: Sudo/bin/hostname < host name >
However, when the system starts, the name of the host is read from the/etc/hostname.

2, through the configuration file configuration

1 Configure IP Gateway: sudo gedit/etc/network/interfaces inside add

of DHCP:

Auto Lo
Iface Lo inet Loopback

Auto Eth0
Iface eth0 inet DHCP

Static IP:

Auto Lo
Iface Lo inet Loopback
#上面的是回环
#网卡eth0的配置
Auto Eth0
#staic Static IP
Iface eth0 inet Static
Address 192.168.1.5
Netmask 255.255.255.0
Gateway 192.168.1.1
#network 192.168.3.0
#broadcast 192.168.3.255
#后面两条是网络号和广播号, this can be computed by other information, so there is no need to set



You can also configure a second IP (virtual IP)


Auto Eth0:1
Iface eth0:1 inet Static
Address 192.168.1.60
Netmask 255.255.255.0
#network x.x.x.x
#broadcast x.x.x.x
Gateway x.x.x.x



2) Configure Dns:sudo gedit/etc/resolv.conf

NameServer 202.107.117.11

3 host Name: sudo gedit/etc/hostname enter the hostname. There is a host name by default, so this is not required.

4) Restart Network: sudo/etc/init.d/networking restart

You can also reboot the network card:

sudo ifconfig eth0 down
sudo ifconfig eth0 up

Restarting the NIC has no effect on the other NIC, more recommended.

3, through the Graphical Network connection menu configuration

This is also called Network Manager in the system-preferences, and it can be configured by using the network Management applet in the upper right corner panel.

This is a bit of a problem: it has a common configuration file with the second method, so it can cause conflicts and be aware of it when used.

Instead, both methods are configured, sudo/etc/init.d/networking Restart enables the configuration of the second method, and clicking the Auto eth0 in the network Management applet on the desktop Panel enables the third configuration

SuSE Network Configuration

How to correctly solve SuSE network configuration, here are the SUSE network configuration steps you want. From here you can learn more concise and rapid configuration SuSE Network configuration knowledge. Correct handling of SUSE network configuration.

1.yast run, start the NIC.

2. Enter the/etc/sysconfig/netwrok/and find the corresponding network file. Typically a ifcfg-eth* file.

3.VI ifcfg-eth*

4. Typical Ifcfg-eth0 configuration
bootproto= ' Static '
Broadcast= ' 2.255.255.255 '
Ipaddr= ' 2.2.2.123 '
Mtu= '
netmask= ' 255.0.0.0 '
network= ' 2.0.0.0 '
Remote_ipaddr= '
Startmode= ' Onboot '
_nm_name= ' static-0 '

5./etc/init.d/network Start Network

6. Temporary ip:ifconfig eth0 2.2.2.123 up

7. Terminate and start a network card: Ifdown eth0, Ifup eth0

8.IFCONFIG-A Displays the IP configuration.

This completes the SUSE network 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.