Always note---Modify IP access extranet

Source: Internet
Author: User
Tags nameserver


Always note---Modify IP access extranet


Linux Environment:


Add an IP to the NIC:

Ifconfig eth0:1 192.168.0.1 netmask 255.255.255.0

Remove the second IP address of the NIC:

IP addr del 192.168.0.1 dev eth0

This method increases the virtual IP that can be viewed by ifconfig


Another way to increase the virtual IP (ifconfig not seen):


Add Virtual IP:

Ip-f inet addr Add 192.168.146.229/32 brd 192.168.146.229 Dev eth0


To view virtual IP:

Ip-f inet Addr


To delete a virtual IP:

Ip-f inet Addr Delete 192.168.146.229/32 brd 192.168.146.229 dev eth0



1: Temporary modification:

1.1: Modify IP Address

# ifconfig Eth0 192.168.100.100


1.2: Modify the gateway address

# route add default GW 192.168.100.1 dev eth0


1.3: Modify DNS

# echo "NameServer 8.8.8.8" >>/etc/resolv.conf


This time will be able to surf the internet, the IP address of the Internet is 192.168.100.100, the gateway address is 192.168.100.1. However, such a setting is temporary, once the network card restart or restart the server, in addition to 1.3 of other operations will be restored, such a way only suitable for temporary IP modification, want to permanently modify the network card configuration file, you need to modify the corresponding file


2: Permanent modification:

2.1: Modify IP Address

Modify the/etc/sysconfig/network-scripts/ifcfg-eth0 file, if there are more than one network card, then modify the appropriate network card

# Vi/etc/sysconfig/network-scripts/ifcfg-eth0

Device=eth0 #网卡对应的设备别名

Bootproto=static #网卡获得ip地址的方式 (default is DHCP, which means auto get)

HWADDR=00:07:E9:05:E8:B4 #网卡MAC地址 (Physical Address)

ipaddr=192.168.100.100 #IP地址

netmask=255.255.255.0 #子网掩码

Onboot=yes #系统启动时是否激活此设备



2.2: Modify the gateway address

Modify the/etc/sysconfig/network file

# vi/etc/sysconfig/network

Networking=yes #表示系统是否使用网络, no means network is not available

Hostname=doiido #设置本机的主机名 to be the same as the host name set in/etc/hosts

gateway=192.168.100.1 #设置网关的IP地址


You can ping the IP address at this time, but you cannot ping the domain name, so you need to modify the DNS


2.3: Modify DNS

Modify the/etc/resolv.conf file

# vi/etc/resolv.conf

NameServer 8.8.8.8 #google域名服务器

NameServer 114.144.114.114 #国内域名服务器


2.4: Restart the NIC

# Service Network Restart

Shutting down interface eth0: [OK]

Close Loopback interface: [OK]

Eject loopback interface: [OK]

Popup interface eth0: [OK]


This time, the system will be able to surf the internet properly.


 


How to add an IP address or network card to Linux


Solution Solutions


"How to add IP to Linux:"


Cd/etc/sysconfig/network-scripts


LS ifcfg-eth0*


Can see that there are


Ifcfg-eth0


If you have previously been equipped with another IP, there may be


ifcfg-eth0:0


Ifcfg-eth0:1


Wait a minute


If not, edit a ifcfg-eth0:0 file, and if so, add one to the maximum number.


File contents:


Ipaddr= "192.168.0.10"


Netmask= ""


IPADDR is the new IP to add, if there are multiple consecutive IPs, you can write:


Ipaddr= "192.168.0.10-11"


Netmask= ""


When the file is finished editing, run:


/etc/init.d/network Reload


Use Ifconfig to see if the new IP has been added.


"How to configure an IP address for a new NIC"


If you are matching the IP for the second NIC, edit a ifcfg-eth1 file in the/etc/sysconfig/network-scripts directory:


Device=eth1


Onboot=yes


Bootproto=static


ipaddr=192.168.0.18


netmask=255.255.255.0


gateway=192.168.0.1


Modify the parameters of the Ipaddr,netmask and gateway.


Run:


/etc/init.d/network Reload


Use Ifconfig to see if the new IP has been added.




Today, there is a problem, two machines on hand: A window machine, a Linux industrial computer.


Problem Description:


1.windows machine ip:10.194.229.170, external network test Platform IP address: 115.238.107.211


2. Then I added an extranet ip:10.194.229.171 on my Linux IPC, and the local Windows and Linux industrial computers could be used to spell each other. But the Linux industrial computer does not work through the external network test Platform address.


Find out the default gateway for window machine is 10.194.229.254, forgot to set a default gateway for Linux industrial computer.


This is just a brief summary of adding IP addresses and default gateways to Linux systems.


Add IP address under 1.linux system


Note: All operations are using the root user

Modify Ip:ifconfig eth0 10.10.22.145//directly change the IP of the first net card to 10.10.22.145

Add ip:ifconfig eth0 Add 10.10.33.145//Add an IP

Add one more ip:ifconfig eth0:0 add 10.10.44.145


The above additions will take effect immediately, but after the machine restarts, it is invalid.


Ifconfig eth0 Add 10.10.44.145

This modifies the newly added IP 10.10.33.145 to 10.10.44.145.


Deletion: IP addr del 192.168.0.1 dev eth0


2.linux ways to add gateways


Temporary Add Method: Route add default GW IP


Delete: Route del default


Permanently Add method: Modify/etc/rc.local. Add a command to a file: route add default GW IP


Takes effect after restarting the network card or machine


3. Modify DNS to modify the/etc/resolv.conf file directly


(such as the Linux industrial computer added a default gateway or not spell Baidu, need to add DNS)

Vi/etc/resolv.conf


Add an available DNS address to the file

NameServer 10.1.7.88



Not to be continued.

This article is from the "• m ¹d#̧ô 6" blog, please be sure to keep this source http://mifan6.blog.51cto.com/9954601/1713263

Always note---Modify IP access extranet

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.