14-1 Ubtuntu 网络配置

发布时间 2023-05-21 20:59:53作者: liujinxi

一、修改网卡名

[root@ubuntu /home/liujinxi]#vim /etc/default/grub   修改配置文件
GRUB_CMDLINE_LINUX="net.ifnames=0"
[root@ubuntu /home/liujinxi]#grub-mkconfig -o /boot/grub/grub.cfg   重新生成grub
[root@ubuntu /home/liujinxi]#reboot

二、修改网卡IP地址

[root@ubuntu ~]#cd /etc/netplan/
[root@ubuntu ~]#cp 01-netcfg.yaml.bak eth0.yaml
   配置静态IP地址
    # This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
       addresses:
         - 10.0.0.129/24
         - 192.168.0.120/24
gateway4:
添加路由
routes:
- to: 10.30.0.0/16
via: 10.20.0.1

[root@ubuntu /etc/netplan]#netplan apply 重启网卡 修改ubuntu root用户登录 远程链接 [root@ubuntu /etc/netplan]#vim /etc/ssh/sshd_config #PermitRootLogin prohibit-password PermitRootLogin yes [root@ubuntu /etc/netplan]#getent shadow root [root@ubuntu /etc/netplan]#passwd 给root分配密码 [root@ubuntu /etc/netplan]#systemctl restart sshd 重启ssh服务