Reputation: 819
I install jenkins on centOS 7 by yum install jenkins
, and start jenkins service jenkins start
.
Now I can access it by localhost
and 127.0.0.1
, but I can't access it by ip (like: 192.168.1.77).
netstat -nltp
result: (I use port: 8088 now)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9100 0.0.0.0:* LISTEN 23208/node_exporter
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 23200/nginx: master
tcp 0 0 127.0.0.1:9168 0.0.0.0:* LISTEN 23177/ruby
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 3053/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1503/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1495/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2856/master
tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN 23200/nginx: master
tcp 0 0 127.0.0.1:9121 0.0.0.0:* LISTEN 23224/redis_exporte
tcp 0 0 127.0.0.1:9090 0.0.0.0:* LISTEN 23166/prometheus
tcp 0 0 127.0.0.1:8899 0.0.0.0:* LISTEN 23258/unicorn maste
tcp 0 0 127.0.0.1:9187 0.0.0.0:* LISTEN 23214/postgres_expo
tcp6 0 0 ::1:9168 :::* LISTEN 23177/ruby
tcp6 0 0 :::22 :::* LISTEN 1503/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1495/cupsd
tcp6 0 0 :::8088 :::* LISTEN 886/java
tcp6 0 0 ::1:25 :::* LISTEN 2856/master
ifconfig
result:
enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.99 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::a62:66ff:fe9e:fba3 prefixlen 64 scopeid 0x20<link>
ether 08:62:66:9e:fb:a3 txqueuelen 1000 (Ethernet)
RX packets 501018 bytes 502734098 (479.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 167889 bytes 16471815 (15.7 MiB)
TX errors 14 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 0 (Local Loopback)
RX packets 11265076 bytes 8998994558 (8.3 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 11265076 bytes 8998994558 (8.3 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:e3:8b:e1 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
with @StephenKing help , it works now:
The reason I think is that, when I execute service iptables stop
, result is :
Redirecting to /bin/systemctl stop iptables.service
Failed to stop iptables.service: Unit iptables.service not loaded.
so I think the firewall is off. In fact CentOS 7 use firewall-cmd --state
result is running
.
After running iptables -F
, I do not know why, but it works now. This is not a good way!!!
Upvotes: 2
Views: 5659
Reputation: 1
This has worked for me on Red Hat Enterprise Linux release 9.1 (Plow)
firewall-cmd --zone=public --add-port=8080/tcp a--permanent
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload
Thank you @Balazs Gunics as you've saved a lot of my time.
Upvotes: 0
Reputation: 2077
Adding this here as it was the first hit on google. I also had to configure the firewall.
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload
Upvotes: 0
Reputation: 81
As seems from your netstat
output, it's an IpV6 binding issue because Java process of Jenkins is listening to IpV6 only:
tcp6 0 0 :::8088 :::* LISTEN 886/java
And seems like your ISP doesn't get you out through IpV6 Address, that's why you can't access Jenkins. You can configure Java-Defaults in the sysconfig file, in my scenario I'm using CentOS 7, so I Modified this line in /etc/sysconfig/jenkins
:
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true"
Then systemctl restart jenkins
, And now it's listening on IPv4:
[root@jenkins ~]# netstat -lntup | grep 8080
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1300/java
Thanks to Link.
Upvotes: 3