hostnamectl and timedatectl
To query and change the system hostname and related settings use hostnamectl command.
┌──(kaliă‰¿kali-1)-[~]
└─$ hostnamectl status
Static hostname: kali-1
Icon name: computer-vm
Chassis: vm đŸ–´
Machine ID: 09da7950e36646a3bf45f583510255ce
Boot ID: f576a4a8a8ed4dd7a3a8d931f03811bc
Virtualization: vmware
Operating System: Kali GNU/Linux Rolling
Kernel: Linux 5.15.0-kali3-amd64
Architecture: x86-64
Hardware Vendor: VMware, Inc.
Hardware Model: VMware Virtual Platform
timedatectl may be used to query and change the system clock and its settings, and enable or disable time synchronization services.
┌──(kaliă‰¿kali-1)-[~]
└─$ timedatectl status
Local time: Sat 2022-04-09 20:25:31 EDT
Universal time: Sun 2022-04-10 00:25:31 UTC
RTC time: Sun 2022-04-10 00:25:31
Time zone: Canada/Eastern (EDT, -0400)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
ip vs ifconfig
Ethernet networks are called ethx (old fashion) or things like enp0s25 (nowadays). Traditionally, ifconfig was the tool to configure or verify a network interface. I am not spending time on that, because the new tool for you is ip command.
ip
The ip command is the new tool for configuring the networking interfaces. You can do many things using it. For example, the ip a command will show you the current interfaces and their configurations:
┌──(kaliă‰¿kali-1)-[~]
└─$ ip a
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:50:56:a5:0a:e7 brd ff:ff:ff:ff:ff:ff
inet 10.0.0.41/24 brd 10.0.0.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::e2a1:a606:635f:a6c/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:50:56:a5:8f:1e brd ff:ff:ff:ff:ff:ff
inet 169.254.0.1/16 brd 169.254.255.255 scope link noprefixroute eth1
valid_lft forever preferred_lft forever
inet6 fe80::d251:b428:6544:a7dc/64 scope link noprefixroute
valid_lft forever preferred_lft forever
Here are more examples from the manual page of ip command:
EXAMPLES
ip addr
Shows addresses assigned to all network interfaces.
ip link set x up
Bring up interface x.
ip link set x down
Bring down interface x.
ip route
Show table routes.
If you need to get information about the each ip object, you can use help keyword after the ip OBJECT_NAME command. For example:
┌──(kaliă‰¿kali-1)-[~]
└─$ ip a help
Usage: ip address {add|change|replace} IFADDR dev IFNAME [ LIFETIME ]
[ CONFFLAG-LIST ]
ip address del IFADDR dev IFNAME [mngtmpaddr]
ip address {save|flush} [ dev IFNAME ] [ scope SCOPE-ID ]
[ to PREFIX ] [ FLAG-LIST ] [ label LABEL ] [up]
ip address [ show [ dev IFNAME ] [ scope SCOPE-ID ] [ master DEVICE ]
[ nomaster ]
[ type TYPE ] [ to PREFIX ] [ FLAG-LIST ]
[ label LABEL ] [up] [ vrf NAME ] ]
ip address {showdump|restore}
IFADDR := PREFIX | ADDR peer PREFIX
[ broadcast ADDR ] [ anycast ADDR ]
[ label IFNAME ] [ scope SCOPE-ID ] [ metric METRIC ]
SCOPE-ID := [ host | link | global | NUMBER ]
FLAG-LIST := [ FLAG-LIST ] FLAG
FLAG := [ permanent | dynamic | secondary | primary |
[-]tentative | [-]deprecated | [-]dadfailed | temporary |
CONFFLAG-LIST ]
CONFFLAG-LIST := [ CONFFLAG-LIST ] CONFFLAG
CONFFLAG := [ home | nodad | mngtmpaddr | noprefixroute | autojoin ]
LIFETIME := [ valid_lft LFT ] [ preferred_lft LFT ]
LFT := forever | SECONDS
TYPE := { amt | bareudp | bond | bond_slave | bridge | bridge_slave |
dummy | erspan | geneve | gre | gretap | ifb |
ip6erspan | ip6gre | ip6gretap | ip6tnl |
ipip | ipoib | ipvlan | ipvtap |
macsec | macvlan | macvtap |
netdevsim | nlmon | rmnet | sit | team | team_slave |
vcan | veth | vlan | vrf | vti | vxcan | vxlan | wwan |
xfrm }
Configure an Interface
You can find the Kali Linux specific path for network configuration in /etc/NetworkManager/system-connections/. Other distributions have other paths. But all under /etc directory:
┌──(kaliă‰¿kali-1)-[~]
└─$ cd /etc/NetworkManager/system-connections/
┌──(kaliă‰¿kali-1)-[/etc/NetworkManager/system-connections]
└─$ ls
'Ethernet connection 1.nmconnection' 'Ethernet connection 2.nmconnection'
Above you can verify that I have two Ethernet connections. Let’s view them:
┌──(kaliă‰¿kali-1)-[/etc/NetworkManager/system-connections]
└─$ sudo cat Ethernet\ connection\ 1.nmconnection
[connection]
id=Ethernet connection 1
uuid=be55c53d-acab-4060-8d00-3f8df6ae0a2b
type=ethernet
interface-name=eth1
permissions=
timestamp=1649378630
[ethernet]
mac-address=00:50:56:A5:8F:1E
mac-address-blacklist=
[ipv4]
address1=169.254.0.1/16
dns-search=
method=manual
[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto
[proxy]
┌──(kaliă‰¿kali-1)-[/etc/NetworkManager/system-connections]
└─$ sudo cat Ethernet\ connection\ 2.nmconnection
[connection]
id=Ethernet connection 2
uuid=9c8be3d8-d7c8-44ee-9006-b58806e73d71
type=ethernet
interface-name=eth0
permissions=
timestamp=1649378630
[ethernet]
mac-address=00:50:56:A5:0A:E7
mac-address-blacklist=
[ipv4]
address1=10.0.0.41/24,10.0.0.1
dns=10.0.0.1;
dns-search=
method=manual
[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto
[proxy]
Now, Let’s edit our Ethernet connection 1.nmconnection and assign it 172.20.8.4/24 IP address with the default gateway of 172.20.8.1 and DNS server of 10.0.0.1
┌──(kaliă‰¿kali-1)-[/etc/NetworkManager/system-connections]
└─$ sudo vi Ethernet\ connection\ 1.nmconnection
[connection]
id=Ethernet connection 1
uuid=be55c53d-acab-4060-8d00-3f8df6ae0a2b
type=ethernet
interface-name=eth1
permissions=
timestamp=1649378630
[ethernet]
mac-address=00:50:56:A5:8F:1E
mac-address-blacklist=
[ipv4]
address1=172.20.8.4/24,172.20.8.1
dns=10.0.0.1;
dns-search=
method=manual
[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto
[proxy]
┌──(kaliă‰¿kali-1)-[/etc/NetworkManager/system-connections]
└─$ sudo ip link set eth1 down
┌──(kaliă‰¿kali-1)-[/etc/NetworkManager/system-connections]
└─$ sudo ip link set eth1 up
┌──(kaliă‰¿kali-1)-[/etc/NetworkManager/system-connections]
└─$ ip a show dev eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:50:56:a5:8f:1e brd ff:ff:ff:ff:ff:ff
inet 172.20.8.4/24 brd 172.20.8.255 scope global noprefixroute eth1
valid_lft forever preferred_lft forever
inet6 fe80::d251:b428:6544:a7dc/64 scope link noprefixroute
valid_lft forever preferred_lft forever