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.




Install and Configure hd-idle on Fedora

hd-idle is a useful program if you want to spin down hard disks after a defined time period.
It is available in fedora repositories. Therefore you can install it using dnf command,

dnf install hd-idle

systemd unit file is available in below path,

/usr/lib/systemd/system/hd-idle.service

The configuration file is available in below path,

/etc/sysconfig/hd-idle

man page of hd-idle (man hd-idle) describes the usage of hd-idle program. It has capability to define a default idle time for all the disks and define idle time for disks individually.

The default log file path is,

/var/log/hd-idle/hd-idle.log

All the informatiion about this utility can be found here,

http://hd-idle.sourceforge.net/

How to add and remove default gateway on Mac OS

Command to delete the default route,

sudo route delete default

Command to add a default route,

sudo route add default <default gateway IP>

How to turn off IPV6 of an interface on MacOS

Command to list the network services,

networksetup -listallnetworkservices

output of the command,

anons-iMac:~ anon$ networksetup -listallnetworkservices
An asterisk (*) denotes that a network service is disabled.
Ethernet
iPhone USB


Command to turn IPV6 off for a particular network service (in this case Ethernet and iPhone USB are the network services I want to modify),

networksetup -setv6off Ethernet
networksetup -setv6off 'iPhone USB'

Sunday, November 4, 2018

Configure Google Chrome to stop opening 5353 port for listening

Today I have noticed that Google Chrome opens a UDP listening port 5353 whenever I open the browser.
After searching about it, I found this solution shuts down the port,

Create a file under /etc/opt/chrome/policies/managed directory

e.g.:  blockport.json

Add this line to the file,
{ "EnableMediaRouter": false }

Finally it will look like this,
[root@localhost ~]# cat /etc/opt/chrome/policies/managed/blockport.json
{ "EnableMediaRouter": false }



Restart the browser. It will not open the port anymore.

Source: https://unix.stackexchange.com/questions/187294/chromium-browser-pepperflashplugin-opening-listening-ports-on-0-0-0-05353


Update,
For latest Google Chrome instances, Above method didn't work and I have found out that disabling "Show notifications when new printers are detected on the network" shutdown port 5353. Please note that I'm using Version 81.0.4044.129 (Official Build) (64-bit) on MacOS