<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>IP address &#8211; Henry Poon&#039;s Blog</title>
	<atom:link href="https://blog.henrypoon.com/blog/tag/ip-address/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.henrypoon.com</link>
	<description></description>
	<lastBuildDate>Wed, 05 Oct 2022 02:52:12 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
<site xmlns="com-wordpress:feed-additions:1">83044199</site>	<item>
		<title>Running Selenium Webdriver on WSL2</title>
		<link>https://blog.henrypoon.com/blog/2020/09/27/running-selenium-webdriver-on-wsl2/</link>
					<comments>https://blog.henrypoon.com/blog/2020/09/27/running-selenium-webdriver-on-wsl2/#respond</comments>
		
		<dc:creator><![CDATA[hp]]></dc:creator>
		<pubDate>Mon, 28 Sep 2020 00:49:34 +0000</pubDate>
				<category><![CDATA[computer stuff]]></category>
		<category><![CDATA[engineering]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[APT]]></category>
		<category><![CDATA[AWK]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[COM]]></category>
		<category><![CDATA[Computer architecture]]></category>
		<category><![CDATA[D]]></category>
		<category><![CDATA[Download]]></category>
		<category><![CDATA[Drive]]></category>
		<category><![CDATA[Error message]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Firefox version history]]></category>
		<category><![CDATA[Flag]]></category>
		<category><![CDATA[Go]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Graphical user interface testing]]></category>
		<category><![CDATA[IME]]></category>
		<category><![CDATA[IP address]]></category>
		<category><![CDATA[ise]]></category>
		<category><![CDATA[It]]></category>
		<category><![CDATA[Lag]]></category>
		<category><![CDATA[lamb]]></category>
		<category><![CDATA[Language]]></category>
		<category><![CDATA[Lie]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Messages]]></category>
		<category><![CDATA[Net]]></category>
		<category><![CDATA[Operating systems]]></category>
		<category><![CDATA[Parameter]]></category>
		<category><![CDATA[PATH]]></category>
		<category><![CDATA[Port]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Resolv.conf]]></category>
		<category><![CDATA[Rolling]]></category>
		<category><![CDATA[Run]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[Sleep]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[STR]]></category>
		<category><![CDATA[Struct]]></category>
		<category><![CDATA[Time]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[Ubuntu version history]]></category>
		<category><![CDATA[USR]]></category>
		<category><![CDATA[Variable]]></category>
		<category><![CDATA[Web development software]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Z]]></category>
		<guid isPermaLink="false">https://blog.henrypoon.com/?p=6269</guid>

					<description><![CDATA[This is a newer version of the post that I made before on how to run Selenium on WSL, but this one is on doing it in WSL2. The instructions are similar at a high level but there are some additional gotchas. You will need: WSL2 setup with Firefox installed (mine uses Ubuntu 20.04) VcXsrv [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">This is a newer version of the post that I made before on <a href="https://blog.henrypoon.com/blog/2017/06/18/running-selenium-webdriver-on-bash-for-windows/" target="_blank" rel="noreferrer noopener">how to run Selenium on WSL</a>, but this one is on doing it in WSL2.  The instructions are similar at a high level but there are some additional gotchas.</p>



<p class="wp-block-paragraph">You will need:</p>



<ul class="wp-block-list"><li><a rel="noreferrer noopener" href="https://msdn.microsoft.com/en-us/commandline/wsl/install_guide" target="_blank">WSL2 setup</a> with Firefox installed (mine uses Ubuntu 20.04)</li><li><a rel="noreferrer noopener" href="https://sourceforge.net/projects/vcxsrv/" target="_blank">VcXsrv</a></li><li><a rel="noreferrer noopener" href="https://github.com/mozilla/geckodriver/releases" target="_blank">geckodriver</a></li></ul>



<h2 class="wp-block-heading">How it works</h2>



<p class="wp-block-paragraph">VcXsrv starts up an X server on the Windows host machine, and what WSL will do is connect to this server to pass on the details of what programs need to be displayed (in this case, the browser window).  Geckodriver is there purely as a middle layer for Selenium to be able to interact with Firefox.</p>



<h2 class="wp-block-heading">VcXsrv setup</h2>



<p class="wp-block-paragraph">This setups the X server so that Windows can display graphical data coming from the Ubuntu instance.</p>



<ol class="wp-block-list"><li>Download and install</li><li>Start it up with the the command line parameter &#8220;-ac&#8221;.  This flag removes access control restrictions for connecting clients (which is okay as long as this server isn&#8217;t exposed on the open Internet and that the only client connecting is the Ubuntu instance)</li><li>Allow connections to VcXsrv on Windows Firewall</li></ol>



<p class="wp-block-paragraph">The &#8220;-ac&#8221; flag and allowing the program through Windows Firewall is pretty important.  When I didn&#8217;t do this, Ubuntu would give me cryptic error messages like &#8220;Broadway display type not supported&#8221;, but once I set up these access controls, everything was fine.</p>



<h2 class="wp-block-heading">Bash setup</h2>



<p class="wp-block-paragraph">Install firefox</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">sudo apt install firefox</code></pre>



<p class="wp-block-paragraph">Export DISPLAY variable in .bashrc (or for whatever terminal you use, maybe .zshrc, etc.)</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">export DISPLAY=$(ip route | awk '{print $3; exit}'):0</code></pre>



<p class="wp-block-paragraph">This will configure your DISPLAY variable to use the IP address listed in the resolv.conf file.  The IP address listed there is the IP address of the X server that will be used for displaying the browser window.</p>



<p class="wp-block-paragraph">Start up VcXsrv as described in the above and then try to open Firefox.  The Firefox window should open.</p>



<h2 class="wp-block-heading">Geckodriver setup</h2>



<p class="wp-block-paragraph">This acts purely as the API interface that allows Selenium to interact with Firefox.  Selenium looks for this executable when controlling the web browser.</p>



<ol class="wp-block-list"><li>Download geckodriver (make sure to get the Linux one and not the Windows one)</li><li>Put it in /usr/bin (or alternatively some other folder in your PATH)</li></ol>



<h2 class="wp-block-heading">Selenium sample on Python</h2>



<p class="wp-block-paragraph">I tend to use Python when running Selenium code, and I haven&#8217;t tried it on another language (I imagine the principles are similar).  Here is a piece of sample code for starting up the browser and opening up a website, but really any Selenium code can be used.</p>



<pre class="wp-block-code"><code lang="python" class="language-python">import time

from selenium import webdriver
from selenium.webdriver import DesiredCapabilities

def execute_with_retry(method, max_attempts):
    e = None
    for i in range(0, max_attempts):
        try:
            return method()
        except Exception as e:
            print(e)
            time.sleep(1)
    if e is not None:
        raise e

capabilities = DesiredCapabilities.FIREFOX
capabilities["marionette"] = True
firefox_bin = "/usr/bin/firefox"
browser = execute_with_retry(lambda: webdriver.Firefox(
    firefox_binary=firefox_bin, capabilities=capabilities), 10)

browser.get("https://www.google.com")

time.sleep(10)

browser.close()</code></pre>



<p class="wp-block-paragraph"></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.henrypoon.com/blog/2020/09/27/running-selenium-webdriver-on-wsl2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">6269</post-id>	</item>
		<item>
		<title>Ubuntu Network Configuration Using Command Line</title>
		<link>https://blog.henrypoon.com/blog/2009/11/21/ubuntu-network-configuration-using-command-line/</link>
					<comments>https://blog.henrypoon.com/blog/2009/11/21/ubuntu-network-configuration-using-command-line/#respond</comments>
		
		<dc:creator><![CDATA[hp]]></dc:creator>
		<pubDate>Sat, 21 Nov 2009 06:47:00 +0000</pubDate>
				<category><![CDATA[computer stuff]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[9]]></category>
		<category><![CDATA[agra]]></category>
		<category><![CDATA[Chan]]></category>
		<category><![CDATA[COM]]></category>
		<category><![CDATA[Computer architecture]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Configuration files]]></category>
		<category><![CDATA[D]]></category>
		<category><![CDATA[Domain name system]]></category>
		<category><![CDATA[Dynamic Host Configuration Protocol]]></category>
		<category><![CDATA[EAR]]></category>
		<category><![CDATA[Find]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Ifconfig]]></category>
		<category><![CDATA[IME]]></category>
		<category><![CDATA[Installation]]></category>
		<category><![CDATA[Internet protocol suite]]></category>
		<category><![CDATA[Internet Standards]]></category>
		<category><![CDATA[IP address]]></category>
		<category><![CDATA[It]]></category>
		<category><![CDATA[Lie]]></category>
		<category><![CDATA[Net]]></category>
		<category><![CDATA[Operating systems]]></category>
		<category><![CDATA[Port]]></category>
		<category><![CDATA[Prompt]]></category>
		<category><![CDATA[Resolv.conf]]></category>
		<category><![CDATA[Routing]]></category>
		<category><![CDATA[Run]]></category>
		<category><![CDATA[STR]]></category>
		<category><![CDATA[Time]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Transport]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">http://henrypoon.mooo.com/blog/ubuntu-network-configuration-using-command-line</guid>

					<description><![CDATA[Source: https://www.ubuntugeek.com/ubuntu-networking-configuration-using-command-line.html The basics for any network based on *nix hosts is the Transport Control Protocol/ Internet Protocol (TCP/IP) combination of three protocols. This combination consists of the Internet Protocol (IP),Transport Control Protocol (TCP), and Universal Datagram Protocol (UDP). By Default most of the users configure their network card during the installation of Ubuntu. You [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Source: <a href="https://www.ubuntugeek.com/ubuntu-networking-configuration-using-command-line.html">https://www.ubuntugeek.com/ubuntu-networking-configuration-using-command-line.html</a></p>



<p class="wp-block-paragraph">The basics for any network based on *nix hosts is the Transport Control Protocol/ Internet Protocol (TCP/IP) combination of three protocols. This combination consists of the Internet Protocol (IP),Transport Control Protocol (TCP), and Universal Datagram Protocol (UDP).</p>



<p class="wp-block-paragraph">By Default most of the users configure their network card during the installation of Ubuntu. You can however, use the ifconfig command at the shell prompt or Ubuntu’s graphical network configuration tools, such as network-admin, to edit your system’s network device information or to add or remove network devices on your system</p>



<p class="wp-block-paragraph"><b>Configure Network Interface Using Command-Line</b><br>You can configure a network interface from the command line using the networking utilities. You configure your network client hosts with the command line by using commands to change your current settings or by editing a number of system files.</p>



<p class="wp-block-paragraph"><b>Configuring DHCP address for your network card</b><br>If you want to configure DHCP address you need to edit the /etc/network/interfaces and you need to enter the following lines replace eth0 with your network interface card</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">sudo vi /etc/network/interfaces</code></pre>



<pre class="wp-block-code"><code lang="bash" class="language-bash"># The primary network interface – use DHCP to find our address
auto eth0
iface eth0 inet dhcp</code></pre>



<p class="wp-block-paragraph"><b>Configuring Static IP address for your network card</b><br>If you want to configure Static IP address you need to edit the /etc/network/interfaces and you need to enter the following lines replace eth0 with your network interface card</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">sudo vi /etc/network/interfaces</code></pre>



<pre class="wp-block-code"><code lang="bash" class="language-bash"># The primary network interface
auto eth0
iface eth0 inet static
address 192.168.3.90
gateway 192.168.3.1
netmask 255.255.255.0
network 192.168.3.0
broadcast 192.168.3.255</code></pre>



<p class="wp-block-paragraph">After entering all the details you need to restart networking services using the following command</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">sudo /etc/init.d/networking restart</code></pre>



<p class="wp-block-paragraph"><b>Setting up Second IP address or Virtual IP address in Ubuntu</b><br>If you are a server system administrator or normal user some time you need to assign a second ipaddress to your Ubuntu machine.For this you need to edit the /etc/network/interfaces file and you need to add the following syntax.Below one is the only example you need to chnage according to your ip address settings</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">sudo vi /etc/network/interfaces</code></pre>



<pre class="wp-block-code"><code lang="bash" class="language-bash">auto eth0:1
iface eth0:1 inet static
address 192.168.1.60
netmask 255.255.255.0
network x.x.x.x
broadcast x.x.x.x
gateway x.x.x.x</code></pre>



<p class="wp-block-paragraph">You need to enter all the details like address,netmask,network,broadcast and gateways values after entering all the values save this file and you need to restart networking services in debian using the following command to take effect of our new ipaddress.<br>After entering all the details you need to restart networking services using the following command</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">sudo /etc/init.d/networking restart</code></pre>



<p class="wp-block-paragraph"><b>Setting your ubuntu stytem hostname </b><br>Setting up your hostname upon a ubuntu installation is very straightforward. You can directly query, or set, the hostname with the hostname command.<br>As an user you can see your current hostname with</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">sudo /bin/hostname</code></pre>



<p class="wp-block-paragraph"><b>Example</b><br>To set the hostname directly you can become root and run</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">sudo /bin/hostname newname</code></pre>



<p class="wp-block-paragraph">When your system boots it will automatically read the hostname from the file /etc/hostname<br>If you want to know more about how to setup host name check <a href="http://www.debianadmin.com/change-hostname-or-server-name-of-a-linux-machine.html" target="_blank" rel="noopener noreferrer">here</a></p>



<p class="wp-block-paragraph"><b>Setting up DNS</b><br>When it comes to DNS setup Ubuntu doesn’t differ from other distributions. You can add hostname and IP addresses to the file /etc/hosts for static lookups.<br>To cause your machine to consult with a particular server for name lookups you simply add their addresses to /etc/resolv.conf.<br>For example a machine which should perform lookups from the DNS server at IP address 192.168.3.2 would have a resolv.conf file looking like this</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">sudo vi /etc/resolv.conf</code></pre>



<p class="wp-block-paragraph">Enter the following details</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">search test.com
nameserver 192.168.3.2</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.henrypoon.com/blog/2009/11/21/ubuntu-network-configuration-using-command-line/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">24</post-id>	</item>
	</channel>
</rss>
