Sunday, November 25, 2018

How to configure wireless network interface using CLI in Fedora Server

I wanted to use my wireless network adapter on Fedora Server (version 29). Even though there are ways configure it graphically on Fedora Server, I wanted to configure it using only CLI with minimum steps.

When I plugged the adapter to my server, it was shown as wlp0s21f0u4,

ip a command output,

wlp0s21f0u4: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000

Therefore I chose wlp0s21f0u4 as my connection name.

Here are the steps I followed,

1. Create a network configuration file in /etc/sysconfig/network-scripts directory. File name: ifcfg-wlp0s21f0u4 (i.e. ifcfg-<connection name>)


Content of the file is,

[root@localhost network-scripts]# cat ifcfg-wlp0s21f0u4
TYPE=Wireless
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=no
NAME=wlp0s21f0u4
ONBOOT=yes
DEVICE=wlp0s21f0u4
ESSID=bla
KEY_MGMT=WPA-PSK
MODE=Managed

The highlighted configuration parameters are important to establish a wireless connection. As you can see the SSID of my wifi network is bla and it uses WPA-PSK security.

2. Create another file to store the wireless key in the same directory. File name: keys-wlp0s21f0u4 (i.e. keys-<connection name>)


Content of the key file is,

[root@localhost network-scripts]# cat keys-wlp0s21f0u4
WPA_PSK=abc123

 As you can see the password is abc123 and it's stored as plain text.

3. Restart NetworkManager,


systemctl restart NetworkManager

4. After a couple of seconds, the network interface should be up,


ip a command output,

wlp0s21f0u4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000

If you encounter issues, you can use journatctl for troubleshooting,

journalctl -xe -u NetworkManager

Create a keyboard shortcut for Menu action in Mac OS X

While I was using my Hackintosh, I noticed that some menu items do not have keyboard shortcuts defined. Some menu items have keyboard shortcuts, but need special keys.
As an example, If you want to select Sleep menu item, there is a special key combination where one of the required keys "Eject" is not available in typical keyboards. However if you have Mac OS compatible keyboard, this will not be an issue.

There are multiple ways to overcome this. The easiest way I found was adding a new keyboard shortcut using system preferences. No additional software or scripting required.

These are the steps I followed to create a shortcut to Sleep menu action,


1. System Preferences -> Keyboard ->  Shortcuts
2. Select "App Shortcuts" from the left pane
3. Click on + (plus) sign
4. Select "All Applications" for "Application" option
5. Type "Sleep" for "Menu Title" Option
6.  Use your preferred key combination for "Keyboard Shortcut" option. I used Command + F12
7. Click on Add button

Adding a custom keyboard shortcut for Sleep menu action


That's it. Command + F12 will be shown as the keyboard shortcut for Sleep in the menu now,

Command + F12 keyboard shortcut assigned for Sleep menu action

Tuesday, November 20, 2018

Firewalld rules required to open nfs services

Fedora server edition comes with nfs server installed. However we need to add several rules for firewalld to access nfs service.

firewall-cmd --add-service=rpc-bind
firewall-cmd --add-service=mountd
firewall-cmd --add-port=2049/tcp
firewall-cmd --add-port=2049/udp


Use --permanent option and then --reload option to make the rules persistent and effective. 

Change a network interface to remove it from being the default gateway in Fedora

Sometimes it's required to change a network interface to avoid it from being the default gateway. This can be easily achieved by changing the network interface configuration file.

The only change required is to change the value of DEFROUTE of the configuration file to no

e.g.:
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp3s0
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=no
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp3s0
UUID=e73d611-501-33ac-9fd-4946bcfdf8
ONBOOT=yes
AUTOCONNECT_PRIORITY=-999
DEVICE=enp3s0

Permanently disable ipv6 on Fedora

There are several ways to disable ipv6 on Fedora. e.g.: changing sysctl, changing the network configuration file.

However if it's required to disable ipv6 system wide in a reliable way, I prefer to disable it using the kernel parameter method.

I'm using Fedora 29 server edition on an UEFI system.

1.  Add ipv6.disable=1 to GRUB_CMDLINE_LINUX parameter listed in /etc/default/grub file,

[root@localhost ~]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="resume=UUID=aee6d21-c4a6-437-a7c6-d80c98ab9 rhgb quiet ipv6.disable=1"
GRUB_DISABLE_RECOVERY="true"


2. Take a backup of the grub configuration file.

cp /boot/efi/EFI/fedora/grub.cfg /boot/efi/EFI/fedora/grub.cf.bk

3. Generate the grub configuration file,

grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg 

4. Reboot

Update 1: It looks like this method breaks firewalld on fedora 29, Therefore I had to revert the changes.

[root@localhost ~]# systemctl status firewalld -l
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2018-11-20 11:11:07 +0530; 5min ago
     Docs: man:firewalld(1)
 Main PID: 1874 (firewalld)
    Tasks: 2 (limit: 4915)
   Memory: 22.8M
   CGroup: /system.slice/firewalld.service
           └─1874 /usr/bin/python3 /usr/sbin/firewalld --nofork --nopid

Nov 20 11:11:06 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
Nov 20 11:11:07 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
Nov 20 11:11:07 localhost.localdomain firewalld[1874]: WARNING: ip6tables not usable, disabling IPv6 firewall.
Nov 20 11:11:07 localhost.localdomain firewalld[1874]: ERROR: UNKNOWN_ERROR: 'ip6tables' backend does not exist
Nov 20 11:11:08 localhost.localdomain firewalld[1874]: ERROR: COMMAND_FAILED: UNKNOWN_ERROR: 'ip6tables' backend does not exist
Nov 20 11:11:08 localhost.localdomain firewalld[1874]: ERROR: '/usr/sbin/iptables-restore -w -n' failed: iptables-restore v1.8.0 (legacy): goto 'PRE_FedoraServer' is not a chain
                                                      
                                                       Error occurred at line: 2
                                                       Try `iptables-restore -h' or 'iptables-restore --help' for more information.
Nov 20 11:11:08 localhost.localdomain firewalld[1874]: ERROR: COMMAND_FAILED: '/usr/sbin/iptables-restore -w -n' failed: iptables-restore v1.8.0 (legacy): goto 'PRE_FedoraServer' is not a chain
                                                      
                                                       Error occurred at line: 2
                                                       Try `iptables-restore -h' or 'iptables-restore --help' for more information.