Home > OS >  Configure Linux network
Configure Linux network

Time:04-15

A, configure the network parameters of the host name
configuration permanent host name
Cn # #] hostname svr7. Tedu. Modify the current
] # echo svr7. Tedu. Cn & gt; The/etc/hostname
] # cat/etc/hostname
Svr7. Tedu. Cn

] # hostname
Svr7. Tedu. Cn

Two, configure the network parameter of the IP address, subnet mask, gateway address
modify the nic command rules (eth0, eth1, for eth2... )
] # ifconfig | head - 2
Ens33: flags=4163 & lt; The UP, the BROADCAST, RUNNING, MULTICAST> Mtu 1500
Mr 00:0 c: he hath a: 72:4 f txqueuelen 1000 (Ethernet)

# #] vim/etc/default/grub grub kernel boot program
GRUB_CMDLINE_LINUX="... The -quiet .net. Ifnames=0 biosdevname=0 "

] # grub2 mkconfig - o/boot/grub2/grub. CFG #
for nic naming rules to take effect
] # reboot
] # ifconfig | head - 2
eth0 : flags=4163 & lt; The UP, the BROADCAST, RUNNING, MULTICAST> Mtu 1500
Inet 192.168.81.132 netmask 255.255.255.0 broadcast 192.168.81.255

nmcli command card named, delete the wrong card named

KVM virtual machine:
/root @ svr7 ~ # nmcli connection show # see
/root @ svr7 ~ # nmcli connection delete eth0
/root @ svr7 ~ # nmcli connection show # see
VMware virtual machine:
/root @ svr7 ~ # nmcli connection show # see
/root @ svr7 ~ # nmcli connection delete ens33
/root @ svr7 ~ # nmcli connection show

/root @ svr7 ~ # nmcli connection show
/root @ svr7 ~ # nmcli connection delete wired connection \ 1
/root @ svr7 ~ # nmcli connection show

nmcli command card name, add card named
[root @ svr7 ~] # nmcli connection add type Ethernet ifname eth0 con - name eth0
Analytic: nmcli connection add type Ethernet device
Nic device called eth0 nmcli command named eth0

/root @ svr7 ~ # nmcli connection show

modify IP address, subnet mask, gateway address [
/root @ svr7 ~ # nmcli connection the modify eth0
Ipv4. Method manual
. Ipv4 addresses 192.168.4.7/24
Ipv4. Gateway 192.168.4.254
Connection. The autoconnect yes ()

/root @ svr7 ~ # nmcli connection to modify card name
Ipv4. The method of manual configuration
Ipv4. Address 192.168.4.7/24
Ipv4. Gateway 192.168.4.254
Every time I boot automatically enabled all parameter

/root @ svr7 ~ # nmcli connection up eth0
# activation/root @ svr7 ~ # ifconfig | head - 2

[b] network adapter configuration file:/etc/sysconfig/network - scripts/ifcfg - eth0


] # cat/etc/sysconfig/network - scripts/ifcfg - eth0

] # route - n # to check the gateway address information

Gateway
192.168.4.254

Three, configure the network parameter of DNS server address

The DNS server: responsible for DNS machine, will resolve domain for the IP address
/etc/resolv. Conf: final effective configuration file

/root @ svr7 ~ # echo nameserver 8.8.8.8 & gt; The/etc/resolv. Conf
/root @ svr7 ~ # cat/etc/resolv. Conf
Nameserver 8.8.8.8



Four, the template of the machine modified

KVM virtual machine: amend the UUID, changes to/dev/vda1
/root @ svr7 ~ # vim/etc/fstab
.
/dev/vda1/boot XFS defaults 0 0
.


VMware virtual machine: amend the UUID, changes to/dev/sda1
/root @ svr7 ~ # vim/etc/fstab


Five, remote management (Linux and Linux)
The installation of packages
[root @ svr7/] # RPM - qa | grep openssh
Openssh - 7.4 - p1-16. El7. X86_64
Openssh server - 7.4 - p1-16. El7. X86_64
Openssh - clients - 7.4 - p1-16. El7. X86_64

SSH remote login tool
The virtual machine A:
[root @ svr7/] # SSH [email protected]
. ... Necting (yes/no)? Yes
# [email protected] 's password: enter the password
/root @ pc207 ~ # touch/root/hahaxixi. TXT
/root @ pc207 ~ # exit
Logout
The Connection to 192.168.4.207 closed.
[root @ svr7/] # cat/root/. SSH/known_hosts # records used to remote control machine


achieve remote management password-less SSH validation
The virtual machine A:
1. Generate a public key (lock) and the private key (key) to validate
/root @ svr7 ~ # SSH - the keygen enter
all the way. Save the key (/root/. SSH/id_rsa) : # enter to set the default save position
. # assphrase) : enter a password for the empty
. Again: # enter password empty
/root @ svr7 ~ # ls/root/. SSH/
Id_rsa (private key) id_rsa, pub (public) known_hosts
2. The public key (lock) is passed to the virtual machine B
/root @ svr7 ~ # SSH - copy - id [email protected]
/root @ svr7 ~ # # test password-less SSH [email protected]
/root @ pc207 ~ # exit
Logout
The Connection to 192.168.4.207 closed.
/root @ svr7 ~ #
The virtual machine B?
/root @ pc207 ~ # ls/root/. SSH/
Authorized_keys (other machine has passed the public key) known_hosts
/root @ pc207 ~ #


security replication tool SCP=SSH + cp
- SCP [-r] user name @ server: path local path
- SCP [-r] local path username @ server: path
The virtual machine A:
] # SCP/etc/passwd [email protected]:/root
] # SCP - r/home [email protected]:/root/
] # SCP [email protected]:/etc/shadow/MNT/

The virtual machine B:
] # ls/root
.
nullnullnullnull
  • Related