commands for modifying IP and DNS in Linux systems

Source: Internet
Author: User
Tags command line ssh nameserver port number

Linux Modify IP, DNS, routing command line settings ubuntu version of the command line set IP

Cat/etc/network/interfaces

# This file describes the network interfaces available on your system

# and how to activate them. For more information, interfaces (5).

# The Loopback network interface

Auto Lo

Iface Lo inet Loopback

# The Primary network interface

Auto Eth0

Iface eth0 inet Static

Address 192.168.1.104

Netmask 255.255.255.0

Network 192.168.1.0

Broadcast 192.168.1.255

Gateway 192.168.1.2

# Dns-* options are implemented by the RESOLVCONF package, if installed

Dns-nameservers 58.22.96.66 218.104.128.106 202.101.138.8

Dns-search. COM

Reboot network card:/etc/init.d/networking Restatr

Redhat Linux version command line set IP:

ifconfig eth0 New IP

Then edit/etc/sysconfig/network-scripts/ifcfg-eth0, modify IP

First, modify the IP address

[Aeolus@db network-scripts]$ VI Ifcfg-eth0

Device=eth0

Onboot=yes

Bootproto=static

ipaddr=219.136.241.211

netmask=255.255.255.128

gateway=219.136.241.254

Second, modify the gateway

Vi/etc/sysconfig/network

Networking=yes

Hostname=aaron

gateway=192.168.1.1

Third, modify DNS

[Aeolus@db etc]$ VI resolv.conf

NameServer 202.96.128.68

NameServer 219.136.241.206

Four, restart network configuration

/etc/init.d/network Restart v. Example

1. Modify IP Address

Immediate effect:

# ifconfig eth0 192.168.0.20 netmask 255.255.255.0

Start in effect:

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

2, modify the default gateway

Immediate effect:

# route add default GW 192.168.0.254

Start in effect:

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

Modify DNS

Modify/etc/resolv.conf

Can be effective immediately after modification

3. Modify Host Name

Immediate effect:

# hostname FC2

Start in effect:

Modify/etc/sysconfig/network

Ps:

Device=eth0

Bootproto=static

ipaddr=192.168.8.85

netmask=255.255.248.0

gateway=192.168.8.1

Hwaddr=00:0uu3:47:2c:d5:40

Onboot=yes

4: Add Linux system Startup items:

Vi/etc/rc.d/rc.local

Modify the port number of the Linux system ssh

Modify the port number of Linux system SSH OS Linux and UNIX are all applicable: Modify the configuration file/etc/ssh/sshd_config, change the inside port to a new one (this port must be no program to use), such as 10022, and then

Kill-hup ' Cat/var/run/sshd.pid ' will do. Note: The existing connection itself will not break because Kill-hup '

Modify the port number of the Linux system ssh

Operating system Linux and UNIX are available:

Modify the configuration file/etc/ssh/sshd_config to change the inside port to a new one (this port must be used without a program), such as 10022,

Then Kill-hup ' Cat/var/run/sshd.pid ' on the line.

Note: The existing connection itself will not break, because Kill-hup ' cat/var/run/sshd.pid ' is just the one that HUP listening, the connection that has been established (different PID) will not break.

To re-enable and log on with the new port, you can exit with the exit command under this login account and log on with the new port!

Note : More wonderful tutorials Please pay attention to the triple computer tutorial section, triple Computer group: 189034526 welcome you to join

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.