In this blog, we will configure a static IP address on Linux-based systems.
Configure Static IP on Ubuntu
The netplan config files are located at /etc/netplan and the default configuration file is /etc/netplan/01-netcfg.yaml
Open the network config file with an editor such as nano:
vi /etc/netplan/01-netcfg.yaml
1 2 3 4 5 6 7 8 9 10 11 |
<span class="line"><span style="color: #D8DEE9FF">network</span><span style="color: #ECEFF4">:</span></span> <span class="line"><span style="color: #D8DEE9FF">version</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">2</span></span> <span class="line"><span style="color: #D8DEE9FF">renderer</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">networkd</span></span> <span class="line"><span style="color: #D8DEE9FF">ethernets</span><span style="color: #ECEFF4">:</span></span> <span class="line"><span style="color: #D8DEE9FF">ens35</span><span style="color: #ECEFF4">:</span></span> <span class="line"><span style="color: #D8DEE9FF">dhcp4</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">no</span></span> <span class="line"><span style="color: #D8DEE9FF">dhcp6</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">no</span></span> <span class="line"><span style="color: #D8DEE9FF">addresses</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> [</span><span style="color: #B48EAD">192.168</span><span style="color: #ECEFF4">.</span><span style="color: #B48EAD">20.1</span><span style="color: #81A1C1">/</span><span style="color: #B48EAD">24</span><span style="color: #D8DEE9FF">]</span></span> <span class="line"><span style="color: #D8DEE9FF">gateway4</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">192.168</span><span style="color: #ECEFF4">.</span><span style="color: #B48EAD">20.21</span></span> <span class="line"><span style="color: #D8DEE9FF">nameservers</span><span style="color: #ECEFF4">:</span></span> <span class="line"><span style="color: #D8DEE9FF">addresses</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> [</span><span style="color: #B48EAD">1.1</span><span style="color: #ECEFF4">.</span><span style="color: #B48EAD">1.1</span><span style="color: #ECEFF4">,</span><span style="color: #B48EAD">8.8</span><span style="color: #ECEFF4">.</span><span style="color: #B48EAD">8.8</span><span style="color: #D8DEE9FF">]</span></span> |
Once all your changes have been made, you can apply them by running:
sudo netplan apply
Configuring a DHCP address with Netplan
If you’d like to configure your Ubuntu server to run on DHCP this is how we will do it.
1 2 3 4 5 6 7 |
<span class="line"><span style="color: #D8DEE9FF">network</span><span style="color: #ECEFF4">:</span></span> <span class="line"><span style="color: #D8DEE9FF">version</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> </span><span style="color: #B48EAD">2</span></span> <span class="line"><span style="color: #D8DEE9FF">renderer</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">networkd</span></span> <span class="line"><span style="color: #D8DEE9FF">ethernets</span><span style="color: #ECEFF4">:</span></span> <span class="line"><span style="color: #D8DEE9FF">ens35</span><span style="color: #ECEFF4">:</span></span> <span class="line"><span style="color: #D8DEE9FF">dhcp4</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">yes</span></span> <span class="line"><span style="color: #D8DEE9FF">dhcp6</span><span style="color: #ECEFF4">:</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">yes</span></span> |
Once all your changes have been made, you can apply them by running:
sudo netplan apply
Configure Static IP on Redhat/ Ubuntu
For RedHat-based systems, all net config info is under /etc/sysconfig/network-scripts/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
<span class="line"></span> <span class="line"><span style="color: #D8DEE9FF"># </span><span style="color: #D8DEE9">Locate</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">all</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">adapters</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">on</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">system</span></span> <span class="line"><span style="color: #D8DEE9">nmcli</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">con</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">show</span></span> <span class="line"><span style="color: #D8DEE9">nmcli</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">con</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">device</span></span> <span class="line"></span> <span class="line"><span style="color: #D8DEE9FF"># </span><span style="color: #D8DEE9">Locate</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">all</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">existing</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">IP</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">Address</span></span> <span class="line"><span style="color: #D8DEE9">ip</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">a</span></span> <span class="line"></span> <span class="line"><span style="color: #D8DEE9FF"># </span><span style="color: #D8DEE9">To</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">assign</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">a</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">IP</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">address</span></span> <span class="line"></span> <span class="line"><span style="color: #D8DEE9">nmcli</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">con</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">add</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">con</span><span style="color: #81A1C1">-</span><span style="color: #D8DEE9">name</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">ens224</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">type</span><span style="color: #D8DEE9FF"> ethernet ifname ens224 ipv4.method manual ipv4.addresses 172.16.99.102/24</span></span> <span class="line"><span style="color: #D8DEE9FF">Connection 'ens224' (6723bfce-5f84-4401-b995-c9fc4457e8b2) successfully added.</span></span> <span class="line"></span> <span class="line"><span style="color: #D8DEE9FF"># To assign a gateway</span></span> <span class="line"><span style="color: #D8DEE9FF"> nmcli con mod ens224 ipv4.gateway 192.168.99.253</span></span> <span class="line"></span> <span class="line"><span style="color: #D8DEE9FF"># To configure a static IP</span></span> <span class="line"><span style="color: #D8DEE9FF">nmcli con mod ens224 ipv4.method manual</span></span> <span class="line"></span> <span class="line"><span style="color: #D8DEE9FF">#To add DNS entry</span></span> <span class="line"><span style="color: #D8DEE9FF"> nmcli con mod ens224 ipv4.dns "192.168.11.10"</span></span> <span class="line"><span style="color: #D8DEE9FF"> </span></span> <span class="line"><span style="color: #D8DEE9FF"># </span><span style="color: #D8DEE9">Reload</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">the</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">interface</span></span> <span class="line"><span style="color: #D8DEE9FF">nmcli con up ens224</span></span> <span class="line"></span> <span class="line"><span style="color: #D8DEE9FF"># To restart network services</span></span> <span class="line"><span style="color: #D8DEE9FF">systemctl restart network</span></span> <span class="line"><span style="color: #D8DEE9FF">or</span></span> <span class="line"><span style="color: #D8DEE9FF">systemctl restart network.service</span></span> <span class="line"></span> |
Configure Secondary IP on Redhat/ Ubuntu
1 2 3 |
<span class="line"><span style="color: #A6ACCD"># </span><span style="color: #E4F0FB">To</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">add</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">a</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">secondary</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">ip</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">to</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">the</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">same</span><span style="color: #A6ACCD"> </span><span style="color: #91B4D5">interface</span><span style="color: #A6ACCD"> </span><span style="color: #A6ACCDC0">using</span><span style="color: #A6ACCD"> </span><span style="color: #A6ACCDC0">nmcli</span><span style="color: #A6ACCD"> </span><span style="color: #A6ACCDC0">command</span></span> <span class="line"><span style="color: #A6ACCD"> </span><span style="color: #A6ACCDC0">nmcli</span><span style="color: #A6ACCD"> </span><span style="color: #A6ACCDC0">con</span><span style="color: #A6ACCD"> </span><span style="color: #A6ACCDC0">mod</span><span style="color: #A6ACCD"> </span><span style="color: #A6ACCDC0">ens224</span><span style="color: #A6ACCD"> +</span><span style="color: #A6ACCDC0">ipv4</span><span style="color: #A6ACCD">.</span><span style="color: #A6ACCDC0">addresses</span><span style="color: #A6ACCD"> "172.16.99.103/24"</span></span> <span class="line"></span> |
Disable Network Interfaces on Redhat using NMCLI
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
<span class="line"><span style="color: #BABED8"># To Shut an </span><span style="color: #C792EA">interface</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">using</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">if</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">up</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">and</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">down</span></span> <span class="line"><span style="color: #FFCB6B">ifup</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">ens160</span></span> <span class="line"><span style="color: #FFCB6B">ifdown</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">ens160</span></span> <span class="line"></span> <span class="line"></span> <span class="line"><span style="color: #BABED8"># </span><span style="color: #FFCB6B">To</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">Show</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">All</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">network</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">connections</span></span> <span class="line"></span> <span class="line"><span style="color: #BABED8">[</span><span style="color: #FFCB6B">root</span><span style="color: #BABED8">@</span><span style="color: #FFCB6B">san</span><span style="color: #BABED8"> ~]# </span><span style="color: #FFCB6B">nmcli</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">con</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">show</span></span> <span class="line"><span style="color: #FFCB6B">NAME</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">UUID</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">TYPE</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">DEVICE</span><span style="color: #BABED8"> </span></span> <span class="line"><span style="color: #FFCB6B">ens160</span><span style="color: #BABED8"> 9</span><span style="color: #FFCB6B">ecab589</span><span style="color: #BABED8">-8</span><span style="color: #FFCB6B">a09</span><span style="color: #BABED8">-3</span><span style="color: #FFCB6B">e57</span><span style="color: #BABED8">-8895-</span><span style="color: #FFCB6B">a0d118b39be0</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">ethernet</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">ens160</span><span style="color: #BABED8"> </span></span> <span class="line"><span style="color: #FFCB6B">lo</span><span style="color: #BABED8"> 2156</span><span style="color: #FFCB6B">d16c</span><span style="color: #BABED8">-52</span><span style="color: #FFCB6B">b9</span><span style="color: #BABED8">-4</span><span style="color: #FFCB6B">bb6</span><span style="color: #BABED8">-</span><span style="color: #FFCB6B">a05c</span><span style="color: #BABED8">-83240</span><span style="color: #FFCB6B">ecf43cc</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">loopback</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">lo</span><span style="color: #BABED8"> </span></span> <span class="line"><span style="color: #FFCB6B">Wired</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">connection</span><span style="color: #BABED8"> 1 </span><span style="color: #FFCB6B">f945af43</span><span style="color: #BABED8">-4358-34</span><span style="color: #FFCB6B">ad</span><span style="color: #BABED8">-91</span><span style="color: #FFCB6B">ce</span><span style="color: #BABED8">-</span><span style="color: #FFCB6B">b50c8c0d6444</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">ethernet</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">ens224</span><span style="color: #BABED8"> </span></span> <span class="line"><span style="color: #BABED8">[</span><span style="color: #FFCB6B">root</span><span style="color: #BABED8">@</span><span style="color: #FFCB6B">san</span><span style="color: #BABED8"> ~]# </span></span> <span class="line"></span> <span class="line"><span style="color: #BABED8"># </span><span style="color: #FFCB6B">To</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">Shut</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">an</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">interface</span></span> <span class="line"></span> <span class="line"><span style="color: #BABED8">[</span><span style="color: #FFCB6B">root</span><span style="color: #BABED8">@</span><span style="color: #FFCB6B">san</span><span style="color: #BABED8"> ~]# </span><span style="color: #FFCB6B">nmcli</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">connection</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">down</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">Wired</span><span style="color: #BABED8">\ </span><span style="color: #FFCB6B">connection</span><span style="color: #BABED8">\ 1 </span></span> <span class="line"><span style="color: #FFCB6B">Connection</span><span style="color: #BABED8"> '</span><span style="color: #FFCB6B">Wired</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">connection</span><span style="color: #BABED8"> 1' </span><span style="color: #FFCB6B">successfully</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">deactivated</span><span style="color: #BABED8"> (</span><span style="color: #FFCB6B">D</span><span style="color: #BABED8">-</span><span style="color: #FFCB6B">Bus</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">active</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">path</span><span style="color: #BABED8">: /</span><span style="color: #FFCB6B">org</span><span style="color: #BABED8">/</span><span style="color: #FFCB6B">freedesktop</span><span style="color: #BABED8">/</span><span style="color: #FFCB6B">NetworkManager</span><span style="color: #BABED8">/</span><span style="color: #FFCB6B">ActiveConnection</span><span style="color: #BABED8">/4)</span></span> <span class="line"><span style="color: #BABED8">[</span><span style="color: #FFCB6B">root</span><span style="color: #BABED8">@</span><span style="color: #FFCB6B">san</span><span style="color: #BABED8"> ~]# </span></span> <span class="line"></span> <span class="line"><span style="color: #BABED8"># </span><span style="color: #FFCB6B">To</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">Show</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">All</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">network</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">connections</span></span> <span class="line"></span> <span class="line"><span style="color: #BABED8">[</span><span style="color: #FFCB6B">root</span><span style="color: #BABED8">@</span><span style="color: #FFCB6B">san</span><span style="color: #BABED8"> ~]# </span><span style="color: #FFCB6B">nmcli</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">device</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">status</span><span style="color: #BABED8"> </span></span> <span class="line"><span style="color: #FFCB6B">DEVICE</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">TYPE</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">STATE</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">CONNECTION</span><span style="color: #BABED8"> </span></span> <span class="line"><span style="color: #FFCB6B">ens160</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">ethernet</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">connected</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">ens160</span><span style="color: #BABED8"> </span></span> <span class="line"><span style="color: #FFCB6B">lo</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">loopback</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">connected</span><span style="color: #BABED8"> (</span><span style="color: #FFCB6B">externally</span><span style="color: #BABED8">) </span><span style="color: #FFCB6B">lo</span><span style="color: #BABED8"> </span></span> <span class="line"><span style="color: #FFCB6B">ens224</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">ethernet</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">disconnected</span><span style="color: #BABED8"> -- </span></span> <span class="line"><span style="color: #BABED8">[</span><span style="color: #FFCB6B">root</span><span style="color: #BABED8">@</span><span style="color: #FFCB6B">san</span><span style="color: #BABED8"> ~]# </span></span> <span class="line"></span> <span class="line"><span style="color: #BABED8"># </span><span style="color: #FFCB6B">To</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">Up</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">an</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">interface</span></span> <span class="line"></span> <span class="line"><span style="color: #BABED8">[</span><span style="color: #FFCB6B">root</span><span style="color: #BABED8">@</span><span style="color: #FFCB6B">san</span><span style="color: #BABED8"> ~]# </span><span style="color: #FFCB6B">nmcli</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">connection</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">up</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">Wired</span><span style="color: #BABED8">\ </span><span style="color: #FFCB6B">connection</span><span style="color: #BABED8">\ 1 </span></span> <span class="line"><span style="color: #FFCB6B">Connection</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">successfully</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">activated</span><span style="color: #BABED8"> (</span><span style="color: #FFCB6B">D</span><span style="color: #BABED8">-</span><span style="color: #FFCB6B">Bus</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">active</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">path</span><span style="color: #BABED8">: /</span><span style="color: #FFCB6B">org</span><span style="color: #BABED8">/</span><span style="color: #FFCB6B">freedesktop</span><span style="color: #BABED8">/</span><span style="color: #FFCB6B">NetworkManager</span><span style="color: #BABED8">/</span><span style="color: #FFCB6B">ActiveConnection</span><span style="color: #BABED8">/5)</span></span> <span class="line"><span style="color: #BABED8">[</span><span style="color: #FFCB6B">root</span><span style="color: #BABED8">@</span><span style="color: #FFCB6B">san</span><span style="color: #BABED8"> ~]# </span></span> <span class="line"><span style="color: #BABED8">[</span><span style="color: #FFCB6B">root</span><span style="color: #BABED8">@</span><span style="color: #FFCB6B">san</span><span style="color: #BABED8"> ~]# </span></span> <span class="line"></span> <span class="line"><span style="color: #BABED8"># </span><span style="color: #FFCB6B">To</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">Add</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">a</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">GW</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">to</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">interface</span></span> <span class="line"><span style="color: #FFCB6B">route</span><span style="color: #BABED8"> </span><span style="color: #FFCB6B">add</span><span style="color: #BABED8"> -</span><span style="color: #FFCB6B">net</span><span style="color: #BABED8"> 192.168.11.0 </span><span style="color: #FFCB6B">netmask</span><span style="color: #BABED8"> 255.255.255.0 </span><span style="color: #FFCB6B">gw</span><span style="color: #BABED8"> 192.168.11.253</span></span> <span class="line"></span> <span class="line"></span> |
Check Network Usage Statistics
ethtool is an excellent utility for checking the network card status
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<span class="line"><span style="color: #A6ACCD"># </span><span style="color: #E4F0FB">Install</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">ethtool</span><span style="color: #A6ACCD"> </span></span> <span class="line"><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">yum</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">install</span><span style="color: #A6ACCD"> </span><span style="color: #91B4D5">-</span><span style="color: #E4F0FB">y</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">ethtool</span></span> <span class="line"></span> <span class="line"><span style="color: #A6ACCD"># </span><span style="color: #E4F0FB">View</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">card</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">stats</span></span> <span class="line"><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">ethtool</span><span style="color: #A6ACCD"> </span><span style="color: #91B4D5">-</span><span style="color: #E4F0FB">S</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">ens224</span><span style="color: #A6ACCD"> </span></span> <span class="line"></span> <span class="line"><span style="color: #A6ACCD"># </span><span style="color: #E4F0FB">Check</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">Auto</span><span style="color: #91B4D5">-</span><span style="color: #E4F0FB">negotiation</span><span style="color: #A6ACCD">, </span><span style="color: #E4F0FB">RX</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">and</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">TX</span><span style="color: #A6ACCD"> </span><span style="color: #91B4D5">of</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">a</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">Particular</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">Interface</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">on</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">Linux</span></span> <span class="line"><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">ethtool</span><span style="color: #A6ACCD"> </span><span style="color: #91B4D5">-</span><span style="color: #E4F0FB">a</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">ens224</span></span> <span class="line"></span> <span class="line"><span style="color: #A6ACCD"># </span><span style="color: #E4F0FB">Change</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">speed</span></span> <span class="line"><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">ethtool</span><span style="color: #A6ACCD"> </span><span style="color: #91B4D5">-</span><span style="color: #E4F0FB">s</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">ens224</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">speed</span><span style="color: #A6ACCD"> </span><span style="color: #5DE4C7">100</span></span> <span class="line"><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">ip</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">link</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">set</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">ens224</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">up</span></span> <span class="line"></span> <span class="line"></span> <span class="line"><span style="color: #A6ACCD"># </span><span style="color: #E4F0FB">Enable</span><span style="color: #91B4D5">/</span><span style="color: #E4F0FB">Disable</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">Auto</span><span style="color: #91B4D5">-</span><span style="color: #E4F0FB">Negotiation</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">for</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">Ethernet</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">Device</span></span> <span class="line"><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">ethtool</span><span style="color: #A6ACCD"> </span><span style="color: #91B4D5">-</span><span style="color: #E4F0FB">s</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">ens224</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">autoneg</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">off</span></span> <span class="line"><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">ethtool</span><span style="color: #A6ACCD"> </span><span style="color: #91B4D5">-</span><span style="color: #E4F0FB">s</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">ens224</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">autoneg</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">on</span></span> <span class="line"></span> <span class="line"><span style="color: #A6ACCD"># </span><span style="color: #E4F0FB">Making</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">changes</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">persistent</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">will</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">need</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">an</span><span style="color: #A6ACCD"> </span><span style="color: #E4F0FB">entry</span><span style="color: #A6ACCD"> </span><span style="color: #A6ACCDC0">as</span><span style="color: #A6ACCD"> </span><span style="color: #A6ACCDC0">shown</span></span> <span class="line"></span> <span class="line"><span style="color: #E4F0FB">vi</span><span style="color: #A6ACCD"> </span><span style="color: #91B4D5">/</span><span style="color: #E4F0FB">etc</span><span style="color: #91B4D5">/</span><span style="color: #E4F0FB">sysconfig</span><span style="color: #91B4D5">/</span><span style="color: #E4F0FB">network</span><span style="color: #91B4D5">-</span><span style="color: #E4F0FB">scripts</span><span style="color: #91B4D5">/</span><span style="color: #E4F0FB">ifcfg</span><span style="color: #91B4D5">-</span><span style="color: #E4F0FB">ens224</span></span> <span class="line"><span style="color: #E4F0FB">ETHTOOL_OPTS</span><span style="color: #91B4D5">=</span><span style="color: #A6ACCD">"</span><span style="color: #5DE4C7">speed 1000 duplex full autoneg off</span><span style="color: #A6ACCD">"</span></span> |
Check Port Usage Statistics
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<span class="line"><span style="color: #F6F6F4">netstat </span><span style="color: #F286C4">-</span><span style="color: #F6F6F4">a </span><span style="color: #F286C4">|</span><span style="color: #F6F6F4"> more</span></span> <span class="line"></span> <span class="line"><span style="color: #F6F6F4">netstat </span><span style="color: #F286C4">-</span><span style="color: #F6F6F4">ltnp </span><span style="color: #F286C4">|</span><span style="color: #F6F6F4"> grep </span><span style="color: #F286C4">-</span><span style="color: #F6F6F4">w </span><span style="color: #DEE492">'</span><span style="color: #E7EE98">:80</span><span style="color: #DEE492">'</span><span style="color: #F6F6F4"> </span></span> <span class="line"><span style="color: #F6F6F4"># netstat </span><span style="color: #F286C4">-</span><span style="color: #F6F6F4">o state established </span><span style="color: #DEE492">'</span><span style="color: #E7EE98">( sport = :http or sport = :https )</span><span style="color: #DEE492">'</span></span> <span class="line"></span> <span class="line"><span style="color: #F6F6F4">To scan all open</span><span style="color: #F286C4">/</span><span style="color: #F6F6F4">listening ports </span><span style="color: #F286C4">in</span><span style="color: #F6F6F4"> your Linux system, run the following </span><span style="color: #62E884">command</span><span style="color: #F6F6F4"> (which should take a long time to complete).</span></span> <span class="line"><span style="color: #F6F6F4">$ sudo nmap </span><span style="color: #F286C4">-</span><span style="color: #F6F6F4">n </span><span style="color: #F286C4">-</span><span style="color: #F6F6F4">PN </span><span style="color: #F286C4">-</span><span style="color: #F6F6F4">sT </span><span style="color: #F286C4">-</span><span style="color: #F6F6F4">sU </span><span style="color: #F286C4">-</span><span style="color: #F6F6F4">p</span><span style="color: #F286C4">-</span><span style="color: #F6F6F4"> localhost</span></span> <span class="line"></span> <span class="line"><span style="color: #F6F6F4">fuser </span><span style="color: #BF9EEE">80</span><span style="color: #F286C4">/</span><span style="color: #F6F6F4">tcp</span></span> <span class="line"></span> <span class="line"><span style="color: #BF9EEE">1.</span><span style="color: #F6F6F4"> Viewing the Network Routing Table</span></span> <span class="line"><span style="color: #F6F6F4"># netstat </span><span style="color: #F286C4">-</span><span style="color: #F6F6F4">nr</span></span> <span class="line"></span> <span class="line"><span style="color: #BF9EEE">2.</span><span style="color: #F6F6F4"> Display Network Interface Statistics</span></span> <span class="line"><span style="color: #F6F6F4"># netstat </span><span style="color: #F286C4">-</span><span style="color: #F6F6F4">ai</span></span> <span class="line"></span> <span class="line"><span style="color: #BF9EEE">3.</span><span style="color: #F6F6F4"> Show Network Connections</span></span> <span class="line"><span style="color: #F6F6F4"># netstat </span><span style="color: #F286C4">-</span><span style="color: #F6F6F4">ant</span></span> <span class="line"></span> <span class="line"><span style="color: #BF9EEE">4.</span><span style="color: #F6F6F4"> Show Network Services</span></span> <span class="line"><span style="color: #F6F6F4">netstat </span><span style="color: #F286C4">-</span><span style="color: #F6F6F4">pnltu</span></span> |