How the Ubuntu system changes your default gateway

Source: Internet
Author: User
Keywords Ubuntu
Tags 192.168.1.1 address aliyun configure configured default dhcp dhcp server

Your server needs to have a single default gateway. A network adapter configured with DHCP automatically assigns a default gateway to the DHCP server, but a network adapter configured with a static IP address needs to manually configure the default gateway. This can be done with a simple command. In this example, the default route uses a newly installed http://www.aliyun.com/zixun/aggregation/32544.html "> wireless network card Wlan0, and most PCs use standard Ethernet card eth0.

[Root@bigboy tmp]# route add default GW 192.168.1.1 Wlan0

In this example, make sure that the IP address is 192.168.1.1 routing/firewall and wlan0 device in a network!

When you are done, you need to update your/etc/sysconfig/network file to reflect this change. This file will configure your default gateway every time Linux starts.

networking=yeshostname=bigboygateway=192.168.1.1

Note: In a Debian based system, the default gateway is a fixed definition in the file/etc/network/interfaces. See the "Debian/ubuntu Network Configuration" section later in this chapter for more details.

Some people may not want to modify a particular network file, but simply add the route add command to the/etc/rc.d/rc.local script file, which is automatically executed each time it starts.

You can also define a default gateway in the NIC configuration file in the/etc/sysconfig/network-scripts directory, but this is risky if you have multiple network adapters that can cause multiple default gateways to be defined. This can cause connectivity problems. If one of the default gateways does not have a route to the destination, all the packages will be lost. and firewalls block packets with irregular serial numbers and unknown sources, which can also hinder your data flow.

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.