RedHat Network Configuration

Source: Internet
Author: User
Linux network configuration is basically implemented by modifying several configuration files. Although you can also use ifconfig to set IP addresses, use route to configure the default gateway, and use hostname to configure the host name, but it will be lost after restart. The following is the relevant configuration file:/ect/hosts: configure the Host Name and IP address corresponding to the local DNS/etc/resolv

Linux network configuration is basically implemented by modifying several configuration files. Although you can also use ifconfig to set IP addresses, use route to configure the default gateway, and use hostname to configure the host name, but it will be lost after restart.

The following are related configuration files:

/Ect/hosts: configure the Host Name and IP address, and provide resolution for the Local Machine

/Etc/resolv. conf configure the domain name (this domain name will take effect when it is not resolved within hosts)

/Etc/sysconfig/network configure host name and gateway

/Etc/sysconfig/network-scripts/ifcfg-eth0 configure network parameters such as IP and Mask

1. Nic Configuration

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

DEVICE = eth0

ONBOOT = yes

BOOTPROTO = static

IPADDR = 192.168.1.250

NETMASK = 255.255.255.0

GATEWAY = 192.168.76.1

Ifconfig eth0 210.34.6.89 netmask 255.255.255.128 broadcast 210.34.6.127

Ifconfig eth0: 0 192.168.0.253 netmask 255.255.255.0

Ifconfig eth0: 1 192.168.0.252 netmask 255.255.255.0

Ifconfig eth0 down

Ifconfig eth0 up

Ii. Multi-nic Configuration:

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

DEVICE = eth0

BOOTPROTO = static

IPADDR = 192.168.1.2

NETMASK = 255.255.255.0

ONBOOT = yes

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

DEVICE = eth1

BOOTPROTO = static

IPADDR = 222.157.4.82

NETMASK = 255.255.255.255.128

ONBOOT = yes

Vi/etc/rc. d/rc. local

Route add-net 192.168.0.0/24 gw 192.168.0.254 dev eth0

Route add-net 222.157.0.0/16 gw 222.157.66.1 dev eth1

3. Gateway Configuration:

Note: add the command to/etc/rc. d/rc. local after setting using the command below. Otherwise, the setting will be automatically cleared after restart!

1. Configure in/etc/sysconfig/network-scripts/ifcfg-eth0;

GATEWAY = 192.168.76.1

2. Configure in/etc/sysconfig/network:

Cat/etc/sysconfig/network

NETWORKING = yes

HOSTNAME = zhaohang.com

GATEWAY = 192.168.76.1

3. Run the following command to set:

If you only need to add a default route, you can set it as follows:

Route add default gw 192.168.1.1

Route del default gw 192.168.1.254 (you can delete the default route. After this method is changed, it will take effect in a few minutes .)

If both NICs require gateways, you can set them as follows:

Route add-net 192.168.0.0/24 gw 192.168.0.254 dev eth0

Route add-net 222.157.0.0/16 gw 222.157.66.1 dev eth1

Note: After you have set the route or the default gateway, you can run the following command to view it:

Route-n

Netstat-rn

Route print (For windows)

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.