Initial Settings : Network Settings2024/04/26 |
Change to static IP addres if you use Ubuntu as a server.
|
|
[1] | The interface name [enp1s0] is different on each environment, replace it to your own one. |
# rename to disable default setting root@localhost:~# mv /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.org
root@localhost:~#
vi /etc/netplan/01-netcfg.yaml # create new network: ethernets: # interface name enp1s0: dhcp4: false # IP address/subnet mask addresses: [10.0.0.30/24] # default gateway # [metric] : set priority (specify it if multiple NICs are set) # lower value is higher priority routes: - to: default via: 10.0.0.1 metric: 100 nameservers: # name server to bind addresses: [10.0.0.10,10.0.0.11] # DNS search base search: [srv.world,server.education] dhcp6: false version: 2 # apply changes root@localhost:~# chmod 600 /etc/netplan/01-netcfg.yaml root@localhost:~# netplan apply
ip address 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 noprefixroute valid_lft forever preferred_lft forever 2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 52:54:00:3c:1c:70 brd ff:ff:ff:ff:ff:ff inet 10.0.0.30/24 brd 10.0.0.255 scope global enp1s0 valid_lft forever preferred_lft forever inet6 fe80::5054:ff:fe3c:1c70/64 scope link valid_lft forever preferred_lft forever |
[2] | If you don't need IPv6, it's possible to disable it like follows. |
root@localhost:~# echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf
root@localhost:~#
root@localhost:~# sysctl -p net.ipv6.conf.all.disable_ipv6 = 1 ip address 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 2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 52:54:00:3c:1c:70 brd ff:ff:ff:ff:ff:ff inet 10.0.0.30/24 brd 10.0.0.255 scope global enp1s0 valid_lft forever preferred_lft forever |
Sponsored Link |