Centos7\kali虚拟机(网络)配置(使用记录)

默认以root用户登录

使用root账户进入系统后,打开’/etc/gdm/custom.conf’文件,在[daemon]下添加两行:

AutomaticLoginEnable=True

AutomaticLogin=root

NAT网络配置

[ruokeqx@localhost ~]$ su
Password: 
[root@localhost ruokeqx]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:d0:f5:71 brd ff:ff:ff:ff:ff:ff
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:19:64:9d brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:19:64:9d brd ff:ff:ff:ff:ff:ff
#添加ip地址
[root@localhost ruokeqx]# ip addr add dev ens32 192.168.136.3/24
[root@localhost ruokeqx]# ping 192.168.136.2
PING 192.168.136.2 (192.168.136.2) 56(84) bytes of data.
64 bytes from 192.168.136.2: icmp_seq=1 ttl=128 time=0.416 ms
64 bytes from 192.168.136.2: icmp_seq=2 ttl=128 time=0.218 ms
^C
--- 192.168.136.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.218/0.317/0.416/0.099 ms
#设置默认路由
[root@localhost ruokeqx]# ip route add default via 192.168.136.2
[root@localhost ruokeqx]# ip route show
default via 192.168.136.2 dev ens32 
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 
192.168.136.0/24 dev ens32 proto kernel scope link src 192.168.136.3 
#配置DNS服务器
[root@localhost ruokeqx]# vi /etc/resolv.conf
[root@localhost ruokeqx]# ping www.baidu.com
PING www.baidu.com (180.101.49.12) 56(84) bytes of data.
64 bytes from 180.101.49.12 (180.101.49.12): icmp_seq=1 ttl=128 time=43.0 ms
64 bytes from 180.101.49.12 (180.101.49.12): icmp_seq=2 ttl=128 time=55.6 ms
^C
--- www.baidu.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 43.085/49.366/55.647/6.281 ms
[root@localhost ruokeqx]# 

# /etc/resolv.conf内容
nameserver 192.168.136.2

拓扑图

上面的重启就没了
下面的时永久的

#centos
cd /etc/sysconfig/network-scripts
vi ifcfg-ens32 
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens32
UUID=3a27d1f6-6f8a-4248-9457-80bcf1a386cf
DEVICE=ens32
ONBOOT=yes
IPADDR=192.168.136.3
GATEWAY=192.168.136.2
NETMASK=255.255.255.0
DNS=192.168.136.2

#kali是 vim /etc/network/interfaces
在原文件下面添加

auto eth0
iface eth0 inet static
address 192.168.136.136
netmask 255.255.255.0
gateway 192.168.136.2

/etc/resolv.conf
里面添加DNS

修改主机名

hostnamectl set-hostname

#比如说我配的ip是192.168.136.3 我设置主机名为 126_3
hostnamectl set-hostname 136_3

重连即可

换个源吧

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

yum update

你可能感兴趣的:(折腾)