Squid proxy at ubuntu 18.04 impossible to connect - google-cloud-platform

I'm new with Google Cloud so I may explain not precise.\
I have VM with Ubuntu 18.04 at Google Cloud Platform and I have installed Squid 3 proxy server on it.
Proxy is already configured a little.
http_port 3128 transparent
auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid/passwd
auth_param basic children 2
auth_param basic realm My Proxy Server
auth_param basic credentialsttl 24 hours
auth_params basic casesensitive off
#add acl rules
acl users proxy_auth REQUIRED
#http access rules
http_access deny !users
http_access allow users
In Google console I can see server's outer IP address but It does not work through it.
The ifconfig command shows next
ens4: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1460
inet 10.156.0.3 netmask 255.255.255.255 broadcast 0.0.0.0
inet6 fe80::4001:aff:fe9c:3 prefixlen 64 scopeid 0x20<link>
ether 42:01:0a:9c:00:03 txqueuelen 1000 (Ethernet)
RX packets 104399 bytes 83418274 (83.4 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 93840 bytes 12598292 (12.5 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 16697 bytes 1149429 (1.1 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 16697 bytes 1149429 (1.1 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
where inet 10.156.0.3 means my inner IP.
I suppose I don't understand some simple rule of work with Google Platform or just with proxy configuration.
May you show me where I'm wrong?
Thank you.

To solve your issue you need to check with nmap which ports are open on your VM and if 3128 is closed set Network tag for your VM and add firewall rule to allow access to it.
I've tried to replicate your issue on my test VM:
create VM instance or use existing one
install Squid
check if Squid is running:
$ sudo systemctl status squid
● squid.service - LSB: Squid HTTP Proxy version 3.x
Loaded: loaded (/etc/init.d/squid; generated)
**Active: active (running)** since Wed 2020-02-19 11:47:50 UTC; 26s ago
check accessibility to Squid with nmap:
$ nmap -Pn 35.XXX.155.XXX
Starting Nmap 7.80 ( https://nmap.org ) at 2020-02-19 12:53 CET
...
Host is up (0.023s latency).
Not shown: 996 filtered ports
PORT STATE SERVICE
22/tcp open ssh
3389/tcp closed ms-wbt-server
8000/tcp closed http-alt
8081/tcp closed blackice-icecap
Squid is not available
edit VM and set Network tag proxy-server
add firewall rule to enable connections to Squid by using Network tag:
$ gcloud compute --project=test-prj firewall-rules create proxy-server-rule --direction=INGRESS --priority=999 --network=default --action=ALLOW --rules=tcp:3128 --source-ranges=0.0.0.0/0 --target-tags=proxy-server
check accessibility to Squid with nmap again
$ nmap -Pn 35.XXX.155.XXX
Starting Nmap 7.80 ( https://nmap.org ) at 2020-02-19 12:53 CET
...
Host is up (0.022s latency).
Not shown: 995 filtered ports
PORT STATE SERVICE
22/tcp open ssh
3128/tcp open squid-http
3389/tcp closed ms-wbt-server
8000/tcp closed http-alt
8081/tcp closed blackice-icecap
now Squid is ready to use.

Related

pkt-gen dpdk not sending any packets issue

i am trying to send udp packets from the dpdk machine using pktgen-dpdk to the DUT. but i cannot see any thing sent in the stats and also nothing received on the DUT.
here is the configuration i am using :
dpdk verion: DPDK 20.11.0
pkt-gen version: 20.11.3
ena driver version: 2.4.0
os :amazon linux 2 aws ec2 instance
the pkt-gen pkt file is as following:
stop 0
set 0 dst mac 02:EC:BC:CD:C7:D6 # i try both dst mac address for the gateway and for the DUT
set 0 src ip 192.168.2.187/24
set 0 dst ip 192.168.2.197
set 0 sport 22
set 0 dport 22
set 0 type ipv4
set 0 proto tcp
set 0 size 64
start 0
i also tried multiple diffrent protocols and even a simple icmp by enabling icmp for the port and using ping4 but nothing is sent. the port status is as follwoing:
port o status
in addition to that when i try to use testpmd to send traffic
i get this :
---------------------- Forward statistics for port 0 ----------------------
RX-packets: 11 RX-dropped: 0 RX-total: 11
TX-packets: 231819494 TX-dropped: 2029505748 TX-total: 2261325242
----------------------------------------------------------------------------
+++++++++++++++ Accumulated forward statistics for all ports+++++++++++++++
RX-packets: 11 RX-dropped: 0 RX-total: 11
TX-packets: 231819494 TX-dropped: 2029505748 TX-total: 2261325242
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
seems all transmissions are immediately dropped
Issue lies in pkt-gen not able identify the DPDK NIC ENA, because it is build in shared library mode. To fix the issue
identify the folder where the ENA PMD is located with find / -name "librte_*.so" | grep ena
set the environment with path with export LD_LIBRARY_PATH=[path to pmd folder]
make sure to run pktgen with arguments -d librte_net_ena.so -l 1-3 -- -P -m "2.0, 3.1"
note: solved the issue via live debug too.

ping: http://google.com: Name or service not known [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 months ago.
The community reviewed whether to reopen this question 5 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I'm using centos7 in virtualbox on windows. And vagrant made it, got ping error with http or https. also curl. someone can help me how to fix it and let it work.
[root#localhost ~]# ping google.com
PING google.com (61.91.161.217) 56(84) bytes of data.
64 bytes from chatenabled.mail.google.com (61.91.161.217): icmp_seq=1 ttl=43 time=404 ms
64 bytes from chatenabled.mail.google.com (61.91.161.217): icmp_seq=2 ttl=43 time=408 ms
64 bytes from chatenabled.mail.google.com (61.91.161.217): icmp_seq=3 ttl=43 time=407 ms
64 bytes from chatenabled.mail.google.com (61.91.161.217): icmp_seq=4 ttl=43 time=408 ms
^C
--- google.com ping statistics ---
5 packets transmitted, 4 received, 20% packet loss, time 4000ms
rtt min/avg/max/mdev = 404.297/407.234/408.956/1.887 ms
[root#localhost ~]# ping https://google.com
ping: https://google.com: Name or service not known
[root#localhost ~]# ping https://61.91.161.217
ping: https://61.91.161.217: Name or service not known
`
resolv.conf
[root#localhost ~]# cat /etc/resolv.conf
nameserver 10.0.2.3
nameserver 8.8.8.8
nameserver 8.8.4.4
search localhost
`
ifconfig
[root#localhost ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::5054:ff:fe73:fb1 prefixlen 64 scopeid 0x20<link>
ether 52:54:00:73:0f:b1 txqueuelen 1000 (Ethernet)
RX packets 610587 bytes 48453952 (46.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 468759 bytes 41290880 (39.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.33.10 netmask 255.255.255.0 broadcast 192.168.33.255
inet6 fe80::a00:27ff:fe0e:ae16 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:0e:ae:16 txqueuelen 1000 (Ethernet)
RX packets 3069145 bytes 2674132747 (2.4 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2531212 bytes 213727091 (203.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
network file automatically created from vagrant
[root#localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
NAME="eth0"
ONBOOT=yes
NETBOOT=yes
UUID="704aa015-53dd-4ba7-9689-b9b8bf6e09a5"
IPV6INIT=yes
BOOTPROTO=dhcp
TYPE=Ethernet
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
HWADDR=52:54:00:73:0f:b1
DNS1=8.8.8.8
[root#localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
NM_CONTROLLED=no
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.33.10
NETMASK=255.255.255.0
DEVICE=eth1
PEERDNS=no
DNS1=8.8.8.8
First make sure you have your network adapter enabled in virtual box settings.
Your network interface which you use it for connecting to internet might not be active.
To check this,use "sudo nmcli d" command.
If it is disconnected,use "sudo nmtui"->Edit a connection,select your network interface and choose "Automatically connect" option(by
pressing Space key) and select OK.
Do "sudo reboot now" After logging in,do "ping www.google.com".
You should be able to connect now.
ping has nothing to do with HTTP or HTTPS:
Ping will use ICMP protocol, it belongs to TCP/IP
Ping operates by sending Internet Control Message Protocol (ICMP) echo request packets to the target host and waiting for an ICMP response.
Actually ping works at a much lower level than HTTP or HTTPS, and only accepts hostnames, not URLs.
change the VirtualBOx network card
use -> Intel PRO/1000 T Server (82543GC)
I tried a lot of different solutions. Changed resolve.conf a billion times. In the end I just needed to restart the router lol. Solved for me I hope it does the same for you.
There is another possibility,If you are a cloned machine, please check the UUID of the server NIC,The UUID is the same, and this will also happen, please delete the UUID。
eg:CentOS 7
cat /etc/sysconfig/network-scripts/ifcfg-ens192
...
UUID=03da7500-2101-c722-2438-xxxxxxx
...
If you are able to ping all the network devices and only facing issue like - ping: http://google.com: Name or service not known , then you should try to remove all the lines and try to put only one nameserver in /etc/resolv.conf . enter image description here
Okay
I tried so many times with all different methods.
But in the end what worked was that my linux system was connected to Internet. I changed to NAT and it worked.
Check /etc/nsswitch.conf and remove the # from below line
networks: files #dns

Jetty remote debug listens on 0.0.0.0?

I was trying remote debug a webapp. Follows the instruction on this jetty document . I got java process like this.
jetty 9682 0.4 2.2 4433620 87568 ? Sl 15:52 0:03 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-0.b17.el6_7.x86_64/jre/bin/java -Xdebug -agentlib:jdwp=transport=dt_socket,address=12000,server=y,suspend=n -Djava.io.tmpdir=/tmp -Djetty.home=/opt/jetty -Djetty.base=/opt/jetty
But the process only listens on 0.0.0.0.
Here is the output of netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:12000 0.0.0.0:* LISTEN
So i can't connect this port on other IP.
My questions how this happen and how to fix it?
EDIT: I was wrong. I was confused by the output of netstat. Because the output of port 8080 is
tcp 0 0 :::8080 :::* LISTEN
I finally realized this may caused by the firewall. I solved the problem by add this port to iptables.
0.0.0.0 means "all IPv4 addresses on the local machine". If a host has two IP addresses, 192.168.1.1 and 10.1.2.1, and a server running on the host listens on 0.0.0.0, it will be reachable at both of those IPs.
From: https://en.wikipedia.org/wiki/0.0.0.0
More info at Is binding to 0.0.0.0 in Java guaranteed to bind to all network interfaces?

VM can't ping the host in VirtualBox host-only networking

My host is MAC OS. In Virtualbox, I create a host-only network whose name is "vboxnet0", where adapter IPv4 address is 192.168.56.1/24, IPv6 disabled and DHCP server disabled.
I have a ubuntu server VM. I enable 2 network adapters for the VM. Adapter1 uses NAT with eth0, Adapter2 uses host-only network "vboxnet0" with eth1. In /etc/network/interfaces, I added the following commands:
auto eth1
iface eth1 inet static
address 192.168.56.50
netmask 255.255.255.0
network 192.168.56.0
broadcast 192.168.56.255
From the host, I can ping the VM; However I can't ping from VM to the host.
Host's routing table
Destination Gateway Flags Refs Use Netif Expire
default 192.168.0.1 UGSc 38 0 en1
127 127.0.0.1 UCS 0 0 lo0
127.0.0.1 127.0.0.1 UH 9 169482 lo0
169.254 link#5 UCS 0 0 en1
192.168.0 link#5 UCS 0 0 en1
192.168.0.1/32 link#5 UCS 1 0 en1
192.168.0.1 84:94:8c:91:1a:f2 UHLWIir 40 25 en1 1194
192.168.0.15/32 link#5 UCS 0 0 en1
192.168.56 link#11 UC 2 0 vboxnet
192.168.56.1 a:0:27:0:0:0 UHLWIi 1 76 lo0
192.168.56.50 8:0:27:9d:5:77 UHLWI 0 5 vboxnet 1084
VM's routing table:
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.0.2.2 0.0.0.0 UG 0 0 0 eth0
10.0.2.0 * 255.255.255.0 U 0 0 0 eth0
192.168.56.0 * 255.255.255.0 U 0 0 0 eth1
VM's arp table:
Address HWtype HWaddress Flags Mask Iface
192.168.56.1 ether 0a:00:27:00:00:00 C eth1
10.0.2.2 ether 52:54:00:12:35:02 C eth0
192.168.56.1's mac address is the same as the configuration on the host. This info means ARP works.
Start wireshark to listen to the interface "vboxnet0" on the host, I can see ARP received and ICMPs received on the host. ICMP packet says:"Expert Info (Warn/Sequence): No response seen to ICMP request in frame 14" (I can't put the screenshot because of lack of reputation)
Firewall settings.
(I know this is an old question, but I hope this will help anyone reading)
I'm not sure about the firewall setting on MAC OS. But on Windows 10, when I can't ping from a Host to VM but can ping from VM to Host. This is caused by Outbound Firewall rule.
If you don't know which part of which device's firewall to configure, start by disabling the whole thing and go from there.

Vagrant CentOS6.3 box forwarded port failure

sh-3.2# vagrant -v
Vagrant 1.4.3
sh-3.2# VBoxManage -v
4.3.6r91406
sh-3.2#
iptables has been removed...
On the vagrant machine I see the port and it responds.
[vagrant#localhost ~]$ nmap localhost
Starting Nmap 5.51 ( http://nmap.org ) at 2014-02-04 04:00 CET
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00028s latency).
Other addresses for localhost (not scanned): 127.0.0.1
Not shown: 998 closed ports
PORT STATE SERVICE
111/tcp open rpcbind
8000/tcp open http-alt
Nmap done: 1 IP address (1 host up) scanned in 0.05 seconds
[vagrant#localhost ~]$ curl localhost:8000
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html>
<title>Directory listing for /</title>
<body>
<h2>Directory listing for /</h2>
<hr>
<ul>
<li>.bash_history
<li>.bash_logout
<li>.bash_profile
<li>.bashrc
<li>.ssh/
<li>.vbox_version
<li>postinstall.sh
</ul>
<hr>
</body>
</html>
[vagrant#localhost ~]$
My ports are forwarded...
[web1] -- 22 => 2222 (adapter 1)
[web1] -- 80 => 8080 (adapter 1)
[web1] -- 8000 => 8081 (adapter 1)
Now... the port on the host looks open...
Starting Nmap 6.40 ( http://nmap.org ) at 2014-02-03 19:02 PST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000014s latency).
Not shown: 811 closed ports, 183 filtered ports
PORT STATE SERVICE
22/tcp open ssh
631/tcp open ipp
2222/tcp open EtherNet/IP-1
7778/tcp open interwise
8080/tcp open http-proxy
8081/tcp open blackice-icecap
Nmap done: 1 IP address (1 host up) scanned in 5.23 seconds
But curl never returns...
sh-3.2# curl localhost:8081
Vagrant/VirtualBox forwards the port to the first (NAT) adapter, so you need to bind your web server to it's IP, or to 0.0.0.0. Probably it's then also easier to add a private_network address and skip port forwarding altogether.