Webserver over Internet not just localhost - vb.net

I have made a "webserver" in vb.net the problem is that it seems like it's just listening to 127.0.0.1 (localhost) and not request that is sent over the internet. I have changed the listening adress to my public internet ip but it's still just listening to local requests.
Do someone have a source code with a working example of how this could be accomplished?
Dim address As IPAddress = IPAddress.Parse(79.138.xxx.xxx)
Dim EndPoint As IPEndPoint = New IPEndPoint(address,8082)
Dim ss As Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
ss.Bind(EndPoint)
ss.Listen(20)

Are you behind any kind of network? This includes a router from your ISP, or generally any hardware other than the simplest of modems.
Easy way to tell would be to do an IPCONFIG and see what your local IP address is set to. To do so, open a command prompt, and enter: ipconfig /all
My output, as an example, is this:
Wireless LAN adapter Wireless Network Connection:
Connection-specific DNS Suffix . : home
Description . . . . . . . . . . . : Intel(R) WiFi Link 5100 AGN
Physical Address. . . . . . . . . : 00-22-FB-8A-59-8E
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 192.168.1.2 (Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Monday, December 27, 2010 7:50:12 PM
Lease Expires . . . . . . . . . . : Tuesday, December 28, 2010 9:13:01 PM
Default Gateway . . . . . . . . . : 192.168.1.1
DHCP Server . . . . . . . . . . . : 192.168.1.1
DNS Servers . . . . . . . . . . . : 192.168.1.1
68.238.0.12
NetBIOS over Tcpip. . . . . . . . : Enabled
This tell me that the IP address of my computer is 192.168.1.2, which is far different than that of my public internet connection, due to being behind a router.
If this is the case, you'll need to open a path from the public world to your specific IP address behind your hardware. This is usually referred to as Port Forwarding or similar, and would be configured in your router/firewall.
Also, as a doublecheck, do you have software firewalls disabled?

Related

Ping -t shows loss when Apache is running

I have an apache server on windows machine , in the same network there is many other machines containing servers also ..
When I try to check the network connectivity usin ping -t GATEWAY_IP , it shows a lot of loss , but when I shutdown the apache server it becomes regular .
I know that ping has nothing to do with apache , but I cant explain that strange thing actually .
So, What can the problem be ?

Hosting database in Xampp (in separate fixed port)

I have successfully hosted database with xampp
https://stackoverflow.com/a/48990347/15493370
This is the link which I followed. Now It works fine but there is one problem. I want the database to be hosted in 192.168.100.2:8080 forever. How can I do that?
Suppose my current Ip is 192.168.100.59.
On using ipconfig
Wireless LAN adapter Wi-Fi:
Connection-specific DNS Suffix . :
IPv4 Address. . . . . . . . . . . : 192.168.100.59
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : fe80::1%12
192.168.100.1
I have not included ipv6 as it is not used anywhere.
I tried using IP 192.168.100.2 in the httpd.conf file. It still listens to 192.168.100.59 not what I want.
So my question is How can I make it host to fixed private Ip in LAN at any time
Or
Will it change overtime
If so how can I solve this problem. (I am not connecting different networks just single network )
You have to statically set your ip address so when your pc/server restarts/reboots it doesn't change its ip.
Alternatively you can create a static lease on dhcp server based on your server's mac address and always assign the same ip to that mac.

hyperv vm not reachable from another computer in network

I am trying to setup a cluster. I have 2 laptops in my LAN.
Laptop 1 windows VM with hyperv enable
Laptop 2 running ubuntu on bare metal.
In laptop 1, I created a VM (ubuntu) using hyperv with default switch. Now I am trying to connect from laptop2 to vm running in laptop 1, but ping doesn't reach the vm.
On the other hand, hyperv vm is able to connect with laptop 2.
I have disabled firewall in hyperv vm and laptop 2.
Could somebody please help me setup network such that connection in both direction is possible? Below are ip addresses details in cases needed.
Laptop 1 host IP details
Wireless LAN adapter Wi-Fi:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::d0aa:e43:2164:18c8%21
IPv4 Address. . . . . . . . . . . : 192.168.1.73
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.254
Laptop 1 hyperv switch IP details:
Ethernet adapter vEthernet (Default Switch):
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::718d:fd08:76a:c25a%54
IPv4 Address. . . . . . . . . . . : 192.168.35.129
Subnet Mask . . . . . . . . . . . : 255.255.255.240
Default Gateway . . . . . . . . . :
Laptop 1 Hyper v based ubuntu VM IP details:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.35.139 netmask 255.255.255.240 broadcast 192.168.35.143
Laptop 2 IP detail
wlp13s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.83 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::42eb:609b:b991:7db4 prefixlen 64 scopeid 0x20<link>

tcp flood attack not works with hping3

i want to do a dos attack to a website in my virtual machine. i use hping3 for that .
sudo hping3 -i u1 -S -c 9999999999 192.168.58.3
in this ip address i have an apache server and a DVWA. when i input this ip address to the browser i see two folder : DVWA and html . when i choose DVWA i see the website.
my problem is than althogh i use hping3 for attack and i want the website get down but the website not down and when i ping this ip address ttls are like when attack not occured. i search a lot and do all works i think . i don't know what is the problem. please help me. thanks
Try this:
$ sudo hping3 -i u1 -S -p 80 192.168.58.3
S - indicates SYN flag
p 80 - Target port 80
i u1 - Wait for 1 micro second between each packet
This would send TCP SYN packets to 192.168.58.3.

Unable to change SELinux security context for the VirtualBox shared folder

I'm facing the following situation. For web development purposes, I've managed to set up a CentOS 7 guest VM with VirtualBox. I've installed a LAMP stack and configured Apache (vhost, added apache member of the group vboxsf, added the firewall rule) to access VirtualBox shared folder.
Configuration setting of the GUEST CentOS 7 VM Guest machine:
Virtual machine hostname: dickwan.dev
Shared Folders:
Name | Read-only | Auto-mount
------------------------------------
dickwan | no | yes
------------------------------------
Networking: NAT (with port forwarding rules)
Port Forwarding Rules:
Name | Protocol | Host IP | Host Port | Guest IP | Guest Port
--------------------------------------------------------------------------------------
HTTP | TCP | . . . | 8080 | . . . | 80
--------------------------------------------------------------------------------------
MariaDB | TCP | . . . | 9306 | . . . | 3306
--------------------------------------------------------------------------------------
SSH | TCP | . . . | 2222 | . . . | 22
Now when in my host machine, I open a browser and navigate to (let us say):
http://dickwan.dev:8080/server-status
I get the message:
Forbidden
You don't have permission to access /server-status on this server.
I've track down the problem to a SELinux security context type problem.
When SELinux is disabled everything works just fine (well... fine yeah hum).
But It feels to me like a bad practice just to shutdown the security feature. I've tried to change the context of the shared folder, but I was not able to conduct the operation
Is there a chance to have access to the shared folder through Apache without deactivating SELinux?
Since the security context of VBox shared folders cannot be changed, you can modify the SELinux security policy to allow Apache to work with the context. It is similar to opening a port in your firewall to expose a certain port to an application.
First, make sure your apache user is part of the group which owns the shared folder, if it is not, you can add it with a command that would look like this (the user/group names can be different on your system):
usermod -aG vboxsf apache
Then, you can use audit2allow to generate a new security policy to work around your issues. Here is a good tutorial.
If you are lazy and only want to allow Apache read access to your VBox shared folders, you can probably adapt the following my_httpd_t.te policy file and use the included commands to apply it on your system.
module my_httpd_t 1.0;
require {
type httpd_t;
type vmblock_t;
class dir read;
class file { read getattr open };
}
#============= httpd_t ==============
allow httpd_t vmblock_t:dir read;
allow httpd_t vmblock_t:file { getattr open read };
# Generated by audit2allow
# To apply this policy:
## checkmodule -M -m -o my_httpd_t.mod my_httpd_t.te
## semodule_package -o my_httpd_t.pp -m my_httpd_t.mod
## semodule -i my_httpd_t.pp
## systemctl restart httpd
I had a similar problem (except Fedora 20 as host and guest OS). What I did:
sudo mount -t vboxsf shared_folder /media/shared_folder
sudo ln -s /media/shared_folder/ /var/www/
sudo chcon -R --reference=/var/www /var/www/shared_folder
And this works for me :)
Before I've tried to set security context to automatically mounted shared folder (by VirtualBox) but without success thus I mount it manually